id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
44,176
makro.lsp
preksi_surveyors-lisp/makro.lsp
;********************************************** ;*************** makro lisp ***************** ;********************************************** ;zajednièka datoteka svih makroa, koja se ;uèitava kod pokretanja AutoCAD-a pa su tipkovnièke ;kratice dostupne odmah, a mogu se koristiti i za VBA ;------------------- VBA makroi --------------- (defun C:ay() (vl-vbarun"autopoli") ) (defun C:kv() (vl-vbarun"konvert") ) (defun C:sp() (vl-vbarun"spoj") ) (defun C:z3() (vl-vbarun"zgrada3D") ) (defun C:ff() (vl-vbarun"front") ) (defun C:nm() (vl-vbarun"Nomenklatura") ) (defun c:zz() (vl-vbarun"zekavac") ) (defun c:rt() (vl-vbarun"rotacija") ) (defun C:kk() (vl-vbarun"kartiranje") ) (defun c:du() (vl-vbarun"dubina") ) (defun c:rc() (vl-vbarun"rec") ) (defun c:ii() (vl-vbarun"iskolcenje") ) (defun c:ip() (vl-vbarun"InterPoli3D") ) (defun c:pk() (vl-vbarun"pokos") ) (defun c:gps() (vl-vbarun"GPSpolozajci") ) (defun c:sa() (vl-vbarun"suma") ) (defun c:lp() (vl-vbarun"layerPlus") ) (defun c:rv() (vl-vbarun"razlika") ) (defun c:vi() (vl-vbarun"visineISK") ) (defun c:oo() (vl-vbarun"o2c") ) (defun c:ko() (vl-vbarun"koordinate") ) (defun c:ss() (vl-vbarun"setOpisa") ) (defun c:rk() (vl-vbarun"rk") ) (defun c:as() (vl-vbarun"aritmetickaSredina") ) (defun c:pm() (vl-vbarun"pomoc") ) (defun c:info() (vl-vbarun"info") ) (defun c:mj() (vl-vbarun"promjenaMjerila") ) (defun c:dof() (vl-vbarun"GPinsert") ;ostavljeno radi kompatibilnosti ) (defun c:gp() (vl-vbarun"GPinsert") ) (defun c:kr() (vl-vbarun"koordinateKriza") ) (defun c:4k() (vl-vbarun"cetiriKriza") ) (defun c:dm() (vl-vbarun"decmre") ) (defun c:ooo() (vl-vbarun"offset3D") ) (defun c:ka() (vl-vbarun"kartiranjeAtt") ) (defun c:a2c() (vl-vbarun"att2csv") ) (defun c:va() (vl-vbarun"visineAtt") ) ;------------------- LISP makroi -------------- (defun c:ee () ;makro lisp koji otvara Windows Explorer u direktoriju ;u kojem se nalazi trenutno aktivni DWG (startapp "explorer" (strcat "/n,/e," (getvar "dwgprefix"))) (princ) ) (defun c:pd() ;popravljanje dijaloga promjenom varijable FILEDIA (setvar "FILEDIA" 1) (princ) ) (defun c:if0() (setvar "cmdecho" 0) (command "_imageframe" "OFF") (command "_regen") (setvar "cmdecho" 1) ) (defun c:if1() (setvar "cmdecho" 0) (command "_imageframe" "ON") (command "_regen") (setvar "cmdecho" 1) ) (defun c:hb() ;hatch to back (command "_draworder" (ssget "_X" '((0 . "HATCH"))) "" "b" ) (prompt "\nHatch2back ... gotovo!")(princ) ) (defun c:fn() (command "_find") ) (defun c:p0() (command "3dpoly") ) (defun c:bb() (ai_draworder "_b") ) (defun c:bf() (ai_draworder "_f") ) (defun c:uo() (command "ucs" "ob" pause ) (command "plan" "") ) (defun c:ww() (COMMAND "ucs" "w" "") (command "plan" "") (princ) )
2,844
Common Lisp
.l
165
15.369697
62
0.607733
preksi/surveyors-lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
7262b7a0eaa5d061bc00f4dae3bc31746679a2c33a13f559e0f3978974b5c07f
44,176
[ -1 ]
44,177
tekst.lsp
preksi_surveyors-lisp/tekst.lsp
;************************************ F R O N T ************************************** ;***** ***** ;***** lisp za ispisivanje frontova ***** ;***** by prexy, 10.07.2001.god. ***** ;***** zadnja promjena by prexy 14.01.2012. ***** ;************************************************************************************* (defun setfr (/ lay stl) (setq lay "0_front") (if (tblsearch "layer" lay) (command "LAYER" "T" lay "U" lay "ON" lay "S" lay "") (command "LAYER" "m" lay "c" "white" "" "s" "" "") ;stvaranje layera );if (setq stl "rec") (if (tblsearch "style" stl) (setvar "textstyle" "rec") (command "STYLE" "rec" "simplex" 0 0.8 0 "N" "N" "N") ;postavljanje text stila );if );setfr (defun c:FR(/ snap stil opi h dec pt1 pt2 pt3 kut duzina) (setvar "cmdecho" 0) ;onemogucavanje ispisa statusne linije (setvar "dimzin" 0) ;postavljanje ispisa nule iza decimalnog zareza (setq stil (getvar "textstyle")) ;spremanje ulazne vrijednosti tekst stila (setfr) ;postavljanje layera i tekst stila (setq opi (open "C:/VB/SET.OPI" "r")) (read-line opi) (read-line opi) (setq h (read (read-line opi))) ;postavljanje visine teksta (setq dec 2) ;postavljanje tocnosti ispisa iza decimalnog zareza (setq pt1 (getpoint "\nPikni 1. toèku:")) (while (/= pt1 nil) (setq pt2 (getpoint "\nPikni 2. toèku:")) (setq snap (getvar "OSMODE")) ;spremanje ulazne vrijednosti osnapa (setq kut (angle pt1 pt2)) ;racunanje kuta u odnosu na os x (setq duzina (distance pt1 pt2)) ;racunanje duzine izmedju tocaka ; setiranje privremenog UCS-a s pravilnom orijentacijom (if (and (> kut (/ PI 2)) (< kut (* 3 (/ PI 2)))) (progn (command "UCS" "o" pt2) (command "UCS" "z" pt2 pt1 "") ) ;progn (progn (command "UCS" "o" pt1) (command "UCS" "z" pt1 pt2 "") ) ;progn ) ;if ; ispis fronta na pola duzine s visinom h i odmakom h/2 (setvar "OSMODE" 0) ;ukidanje osnapa (setq pt3 (list (/ duzina 2) (* h 0.75) 0)) ;tocka upisa teksta (command "TEXT" "j" "c" pt3 h "0" (rtos duzina 2 dec)) (command "UCS" "") ;povratak u World UCS (setvar "OSMODE" snap) ;vracanje osnapa na pocetnu vrijednost (setq pt1 (getpoint "\nPikni 1. toèku:")) ) ;while (setvar "textstyle" stil) (setvar "cmdecho" 1) ;omogucavanje ispisa statusne linije (princ) );FR ;************************************************************** ;*************** Rotacija teksta v 1.1 ************************ ;*************** by prexy, 05.04.2002. ************************ ;************************************************************** ; Opis: tekst se rotira tako da bude okomit na zadanu liniju ; Verzija 1.1: nije bitna poèetna rotacija teksta (defun C:RTT () (command "UNDO" "be" "") (setq snap (getvar "OSMODE")) ;spremanje ulazne vrijednosti osnapa (setvar "CMDECHO" 0) (setq ss (ssget)) (print) (setq pt1 (getpoint "Pikni prvu toèku linije:") pt2 (getpoint "\nPikni drugu toèku linije:")) ;(setq rot (+ (/ pi 2) (angle pt1 pt2))) (setq rot (angle pt1 pt2)) (setq c 0) (if ss (setq e (ssname ss c))) (setvar "OSMODE" 0) ;ukidanje osnapa (while e (setq f (entget e)) (if (= (cdr (assoc 0 f)) "TEXT") (progn (setq inspt (cdr (assoc 10 f))) (setq e ; zamjena kuta rotacije objekta (subst (cons 50 rot) (assoc ' 50 f) f) ) (entmod e) );progn );if (setq c (1+ c)) (setq e (ssname ss c)) );while (command "UNDO" "e" "") (setvar "CMDECHO" 1) (setvar "OSMODE" snap) (princ) ) ;******************************* V I S I N E ******************************** ;***** ***** ;***** lisp za promjenu teksta visina toèaka ***** ;***** by nn ***** ;***** ***** ;************************************************************************************* (defun C:ZS (/ sl br a b bb c r p) (setvar "cmdecho" 0) (setvar "dimzin" 0) ;postavljanje ispisa nule iza decimalnog zareza (princ "\n") (initget "Layer Select") (if (= (getkword "Select<Layer>: ") "Select") (progn (setq sl (ssget)) (setq a (sslength sl) c (1- a)) (while (>= c 0) (if (/= (cdr (assoc 0 (entget (ssname sl c)))) "TEXT") (setq sl (ssdel (ssname sl c) sl)) ) (setq c (1- c)) ) ) (setq sl (ssget "X" (list (cons '8 (getstring "\nLayer: "))))) ) (setq r (getreal "\nRazlika visina: ") p (getint "\nDecimala: ") br 0 b (sslength sl)) (while (< br b) (entmod (subst (cons '1 (strcat (rtos (+ (atof (cdr (assoc 1 (entget (ssname sl br))))) r) 2 p) " ")) (assoc 1 (entget (ssname sl br))) (entget (ssname sl br)) ) ) (setq br (1+ br)) ) (setvar "cmdecho" 1) (princ) );ZS ;******************************* F R O N T E X T ************************************* ;***** ***** ;***** lisp za ispisivanje tekstualnih frontova ***** ;***** by prexy, 08.08.2004.god. ***** ;***** zadnja promjena by prexy 14.01.2012. ***** ;************************************************************************************* (defun frontaj(vrsta / opi h PT1 PT P snap DUZINA) (setq opi (open "C:/VB/SET.OPI" "r")) (read-line opi) (read-line opi) (setq h (read (read-line opi))) ;postavljanje visine teksta (setq PT1(getpoint "\nPikni 1. tocku !")) (while (/= PT1 nil) (setq PT(getpoint "\nPikni 2. tocku !")) (setq snap (getvar "OSMODE")) ;spremanje ulazne vrijednosti osnapa (if (> (car PT1) (car PT)) (progn (setq P PT1 PT1 PT PT P) ) ) (setq DUZINA (distance PT PT1)) (if (= vrsta nil) (progn (setq P (polar PT1 (angle PT1 PT) (/ DUZINA 2)) P1 (polar P (+ (angle PT1 PT) (/ PI 2)) h))) (progn (setq P1 (polar PT1 (angle PT1 PT) (/ DUZINA 2)))) );if (command "osnap" "non") (command "TEXT" "M" P1 h (* (/ 180 pi) (angle PT1 PT)) txt "") (if (= vrsta "inst") (acet-textmask-make-wipeout (entlast) (* 0.5 h) ) );if (setvar "OSMODE" snap) ;vracanje osnapa na pocetnu vrijednost (setq PT1(getpoint "\nPikni 1. tocku !")) );while );frontaj (defun C:ft (/ txt stil) (setvar "cmdecho" 0) (setq txt (getstring (strcat "\Tekst<" (getvar "users1") ">:"))) (if (= txt "") (setq txt (getvar "users1")) (setvar "users1" txt)) (setq stil (getvar "textstyle")) ;spremanje ulazne vrijednosti tekst stila (setfr) ;postavljanje layera i tekst stila (frontaj nil) (setvar "textstyle" stil) );ft ;************************* OZNAKA INSTALACIJE **************************** ;***** ***** ;***** lisp za ispisivanje profila cijevi ili oznake instalacije ***** ;***** by prexy, 15.01.2012.god. ***** ;***** zadnja promjena ***** ;************************************************************************************* (defun c:oi (/ txt stil stl) (setvar "cmdecho" 0) (setq txt (getstring (strcat "\Tekst<" (getvar "users1") ">:"))) (if (= txt "") (setq txt (getvar "users1")) (setvar "users1" txt)) (command "wipeout" "f" "off") (setq stil (getvar "textstyle")) ;spremanje ulazne vrijednosti tekst stila (setq stl "rec") (if (tblsearch "style" stl) (setvar "textstyle" "rec") (command "STYLE" "rec" "simplex" 0 0.8 0 "N" "N" "N") ;postavljanje text stila );if (command "ucsicon" "OFF") (frontaj "inst") (command "ucsicon" "ON") (setvar "textstyle" stil) );oi ;***************************************************************** ; ----------------- MASK USING WIPEOUT FUNCTION ------------------ ; This function draws a wipeout under text TXT using the ; offset value OSET ; - funkcija je preuzeta iz express toolsa - moraju biti ; instalirani da bi lisp radio!!!! ; ---------------------------------------------------------------- ;***************************************************************** (defun acet-textmask-make-wipeout (ENT OSET / TXT TXTLAY TBX WIPOUT TXTYP TXTSTR) (setq TXT (entget ENT (list "*")) ; Get the text's edata TXTLAY (cdr (assoc 8 TXT)) ; Get the layer of the text TXTYP (cdr (assoc 0 TXT)) ; Text or Mtext TXTSTR (cdr (assoc 1 TXT)) ) (if (/= TXTSTR "") (progn (if (= TXTYP "TEXT") (acet-ucs-cmd (list "_object" ENT)) ; set UCS to object (acet-ucs-to-object ENT) ) (setq TBX (acet-geom-textbox TXT OSET)) ; Get the points around the text (if TBX (progn (command "_.pline") ; Create bounding pline box (while TBX (command (car TBX)) (setq TBX (cdr TBX)) ) (command "_c") (command "_.wipeout" "_Polyline" (entlast) "_yes") ; create wipeout entity (setq WIPOUT (entlast)) (command "_.change" WIPOUT "" "_Prop" "_Layer" TXTLAY "") ; and set its layer (acet-ucs-cmd (list "_previous")) ; reset the ucs (entmake TXT) ; recreate text (setq TXT (entlast)) ; such that it's on top (acet-xdata-set (list WIPOUT "ACET-TEXTMASK" (list (list "TextObject" (cdr (assoc 5 (entget TXT))) 1005) (list "Offset" OSET 1040) ) ) ) (acet-xdata-set (list TXT "ACET-TEXTMASK" (list (list "MaskObject" (cdr (assoc 5 (entget WIPOUT))) 1005) (list "MaskType" "WIPEOUT" 1000) (list "Offset" OSET 1040) ) ) ) (command "_.move" TXT "" "0,0" "0,0") (acet-group-make-anon (list WIPOUT TXT) "In use by TEXTMASK") ; make the text and wipeout a group (entdel ENT) ; delete original text ) ); if TBX ); progn then ); if not "" ) ;******************************************************************************** ;******************************************************************************** ; Lisp za opis raznih elemenata crteža ; by pyton ;******************************************************************************** ;******************************************************************************** (defun rad1 () (prompt "ODABERI SEGMENT") (setq h0 h) (setq e (entsel) e1 (car e) e2 (entget e1) ime (cdr (assoc 0 e2)) ) (if (= ime "ARC") (luk) ) (if (= ime "LINE") (duz) ) (if (= ime "POINT") (toc) ) (setq nas (getstring "\n<DALJE> ?")) (if (= nas "") (rad1) (command "redraw") ) ) ;------------------------------ END RAD1 ----------------------------- (defun luk () (setq rr (cdr (assoc 40 e2)) r (rtos rr 2 3) ) (setq f0 (cdr (assoc 50 e2)) f1 (cdr (assoc 51 e2)) c (cdr (assoc 10 e2)) ) (dimarc) ;(setq f (angtos (- f1 f0) s1 s2)) (setq tx1 (strcat "R=" r) tx2 (strcat "L=" (rtos da 2 3)) ) (setq a1 (polar c f1 rr) a2 (polar c f0 rr) ) ;(poi) (stre) (pol) (setq em m2 ha h bee be1 tx tx2 ) (upis) ;(kord) ) ;------------------------------ END LUK ------------------------------ (defun duz () (setq a1 (cdr (assoc 10 e2)) a2 (cdr (assoc 11 e2)) ) (setq l (rtos (distance a1 a2) 2 3) tx1 l ) (pol) ) ;------------------------------ END DUZ ----------------------------- (defun toc () (setq a1 (cdr (assoc 10 e2)) a2 (polar a1 0 1) h0 h ) (setq x1 (rtos (car a1) 2 3) y1 (rtos (cadr a1) 2 3) ) (setq tx3 (strcat x x1) tx4 (strcat y y1) ab a1 mu a1 ) (upi) (pol1) (setq em m1 ha h bee 0 tx tx3 ) (upis) (setq em m2 tx tx4 ) (upis) ) ;------------------------------ END TOC ----------------------------- (defun pol () (setq mu (getpoint "\nmjesto upisa")) (pol1) (setq em m1 ha h bee be1 tx tx1 ) (if (= uv "t") (setq ha (/ ha 2)) ) (upis) ) ;------------------------------ END POL ------------------------------- (defun pol1 () (setq be (angle a1 a2)) (setq m1 (polar mu (+ be (/ pi 2)) (* h0 0.5))) (setq m2 (polar mu (- be (/ pi 2)) (* h0 1.5))) (setq be1 (/ (* 180 be) pi)) (if (> be1 90) (setq be1 (- be1 180)) ) (if (> be1 90) (setq be1 (- be1 180)) ) ) ;------------------------------- END POL1 ----------------------------- (defun stre () (setq b1 (polar a1 (+ f1 pi) (* 10 vs))) (setq b2 (polar a2 (+ f0 pi) (* 10 vs))) (setq a21 (polar a1 (+ f1 pi) (* 2 vs))) (setq a22 (polar a2 (+ f0 pi) (* 2 vs))) (command "dim" "leader" a1 b1 "" "" "exit") (repeat 2 (entdel (entlast))) (command "line" a21 b1 "") (command "dim" "leader" a2 b2 "" "" "exit") (repeat 2 (entdel (entlast))) (command "line" a22 b2 "") ) ;------------------------------- END STRE ----------------------------- (defun kord () (setq x1 (rtos (car a1) 2 3) y1 (rtos (cadr a1) 2 3) ) (setq x2 (rtos (car a2) 2 3) y2 (rtos (cadr a2) 2 3) h0 (/ h 2) ) (setq tx3 (strcat x x1) tx4 (strcat y y1) ab a1 ) ;(upi) (if (/= mu nil) (progn (pol1) (setq em m1 ha h0 tx tx3 ) (upis) (setq em m2 tx tx4 ) (upis) ) ) (setq tx3 (strcat x x2) tx4 (strcat y y2) ab a2 ) ;(upi) (if (/= mu nil) (progn (pol1) (setq em m1 ha h0 tx tx3 ) (upis) (setq em m2 tx tx4 ) (upis) ) ) ) ;-------------------------------- END KORD ----------------------------- (defun upi () ;(command "polygon" "5" ab "i" "2") (setq mu (getpoint "\nmjesto upisa KOORDINATE ")) ;(entdel (entlast)) ) ;------------------------------- END UPI ------------------------------ (defun upis () (command "text" "c" em ha bee tx) ) ;------------------------------- END UPIS ----------------------------- (defun poi () (command "point" a1) (command "point" a2) ) ;------------------------------ END POI ------------------------------- (defun dimarc () (setq df (- f1 f0)) (if (< df 0) (setq df (+ df 6.283185)) ) (setq da (* rr df)) ) ;-----------------------------END DIMARC------------------------------- (defun C:OP () (setvar "cmdecho" 0) (setvar "blipmode" 1) (command "style" "standard" "" 0 1 0 "N" "N" "N") (setvar "dimzin" 0) ;postavljanje ispisa nule iza decimalnog zareza (setq w1 (open "c:/vb/set.opi" "r")) (read-line w1) (setq kw (read (read-line w1))) (setq x "y=" y "x=" ) ;(if (= kw 1) (setq x "y=" y "x=")) (setq h (read (read-line w1)) mis (read (read-line w1)) ) (close w1) (setq s1 1 s2 4 ) (if (= mis 1) (setq s1 0 s2 6 ) ) (setq vs h) (setvar "dimasz" (* 2 vs)) (rad1) ) ;------------------------------ END OPIS -------------------------------
15,789
Common Lisp
.l
487
28.036961
107
0.444459
preksi/surveyors-lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
1b8decec3fab46c5e064d2fbcc890bd55c59fe1c45a91fb7178c7ff9a75da350
44,177
[ -1 ]
44,178
zgrade.lsp
preksi_surveyors-lisp/zgrade.lsp
;***************** Lispovi koji su vezani uz crtanje zgrada ********************* ;******************************************************************************** ; ; Lisp za crtanje zgrade iz tri toèke ; ; by pyton, zadnja promjena 14.01.2012. by prexy ; ;******************************************************************************** (defun c:yy () (setvar "cmdecho" 0) (setq t1 (getpoint "\nPrva toèka :") t2 (getpoint "\nDruga toèka :") ) (command "line" t1 t2 "") (setq e (list (entlast) t1)) (setq lay (cdr (assoc 8 (entget (entlast))))) (setq tl (cdr (assoc 6 (entget (entlast))))) (setq pt (getpoint "\nNaznaèi nasuprotnu toèku :")) (command "offset" "t" e pt "") (setq e1 (entlast) ee nil e3 nil ) (setq e1 (entget e1) t3 (cdr (assoc 10 e1)) t4 (cdr (assoc 11 e1)) ) (command "line" t1 t3 "") (setq e3 (cons (entlast) e3)) (setq ee (cons (entget (entlast)) ee)) (setq os (getvar "OSMODE")) (setvar "OSMODE" 0) (command "line" t2 t4 "") (setq e3 (cons (entlast) e3)) (setq ee (cons (entget (entlast)) ee)) (foreach n ee (progn (setq n (subst (cons 8 lay) (assoc 8 n) n)) (entmod n) ) ) (if (/= tl nil) (foreach n e3 (command "chprop" n "" "lt" tl "")) ) (setvar "OSMODE" os) (princ) ) ;******************************************************************************** ; ; Lisp za crtanje kosih i ravnih šrafura u mjerilu ; ; by pyton, zadnja promjena 14.01.2012. by prexy ; ;******************************************************************************** (defun C:q (/ pt1 pt2 pt3 ent1 snap tip kut opi m) (setvar "cmdecho" 0) (setq snap (getvar "osmode")) ;èitanje trenutne postave OSNAP-a (command "OSNAP" "intersection") ;postavljanje OSNAP-a (initget 1 "Ravna Kosa") ;izbor tipa šrafure (setq tip (getkword "\nTip šrafure? (Ravna ili Kosa) ")) (if (= tip "Ravna") ;postavljanje kuta rotacije šrafure (progn (setq kut 0)) (setq kut -45) );if (setq opi (open "c:/vb/set.opi" "r")) (read-line opi) (setq m (read (read-line opi))) (setq h (* m 0.0012)) ;odreðivanje mjerila šrafure (setq pt2 (getpoint "\n** Odaberi prvu toèku duže stranice : ")) (while (/= pt2 nil) (setq pt3 (getpoint "\n** Odaberi drugu toèku duže stranice : ")) (command "OSNAP" "none") (command "UCS" "3" pt2 pt3 "0,0") ;postavljanje pomoænog UCS-a (setq pt1 (getpoint "\n** Odaberi centar šrafure : ")) (command "boundary" pt1 "") ;kreiranje pomoænog objekta (setq ent1 (cdr (assoc -1 (entget(entlast))))) (setq ss1 (ssadd)) (ssadd ent1 ss1) (command "SCALE" ss1 "" pt1 ".5") ;zatvaranje podruèja šrafure (command "HATCH" "u" kut h "" ss1 "") ;crtanje user-defined hatch-a (command "ERASE" ss1 "") ;brisanje pomoænog objekta (command "UCS" "") ;povratak na World UCS (command "REDRAW" "") (command "OSNAP" "intersection") (setq pt2 (getpoint "\n** Odaberi prvu toèku duže stranice : ")) );while (setvar "osmode" snap) ;vraæanje OSNAP-a na poèetnu postavu (princ) );q ;******************************************************************************** ; ; Lisp za crtanje šrafura prema novom kartografskom kljuèu ; ; by prexy, 04.01.2012. ; ;******************************************************************************** (defun C:qq (/ hpname cc snap tip ss1 lastent pt1 ent1) (setvar "cmdecho" 0) ;ucitaj trenutne vrijednosti sistemskih varijabli (setq hpname (getvar "HPNAME")) (setq cc (getvar "CECOLOR")) (setq snap (getvar "OSMODE"))(setvar "OSMODE" 0) ;izbor vrste objekta (initget 128 "Stambena Gospodarska") (setq tip (getkword "Vrsta zgrade (Stambena ili Gospodarska)<Stambena>: ")) (if (= tip nil) (setq tip "Stambena")) (if (= tip "Stambena") (setvar "CECOLOR" "RGB:150,150,150") (setvar "CECOLOR" "RGB:215,215,215") );if (setvar "HPNAME" "SOLID") (setq ss1 (ssadd)) (setq lastent "") (setq pt1 (getpoint "\n** Odaberi toèku unutar zgrade: ")) (while (/= pt1 nil) (command "_bhatch" "a" "i" "n" "n" "" pt1 "") (setq ent1 (cdr (assoc -1 (entget(entlast))))) (if (/= lastent (assoc -1 (entget(entlast)))) (progn (ssadd ent1 ss1) (setq lastent (assoc -1 (entget(entlast))))) );if (setq pt1 (getpoint "\n** Odaberi toèku unutar zgrade: ")) );while ;postavi srafure iza svega ostaloga (command "_draworder" ss1 "" "b") ;vrati vrijednosti sistemskih varijabli (setvar "HPNAME" hpname) (setvar "CECOLOR" cc) (setvar "OSMODE" snap) (princ) );qq ;******************************************************************************** ; ; Lisp za crtanje šrafura stepenica ; ; by pyton, zadnja promjena 14.01.2012. by prexy ; ;******************************************************************************** (defun C:s (/ pt1 pt2 pt3 ent1 snap opi m h ss1) (setvar "cmdecho" 0) (setq snap (getvar "osmode")) ;èitanje trenutne postave OSNAP-a (command "OSNAP" "INTERSECTION") (command "MEASUREMENT" 1) ;BITNO! ako je postavljeno na 0, neæe dobro raditi!!!! (setq opi (open "c:/vb/set.opi" "r")) (read-line opi) (setq m (read (read-line opi))) (setq h (* m 0.000375)) ;odreðivanje mjerila šrafure (setq pt2 (getpoint "\n** Odaberi prvu toèku duže stranice stepenica : ")) (while (/= pt2 nil) (setq pt3 (getpoint "\n** Odaberi drugu toèku duže stranice stepenica : ")) (command "OSNAP" "NONE") (command "UCS" "3" pt2 pt3 "0,0") (setq pt1 (getpoint "\n** Odaberi centar šrafure : ")) (command "boundary" pt1 "") (setq ent1 (cdr (assoc -1 (entget(entlast))))) (setq ss1 (ssadd)) (ssadd ent1 ss1) (command "HATCH" "LINE" h "90" ss1 "") (command "ERASE" ss1 "") (command "UCS" "") (command "REDRAW" "") (command "OSNAP" "INTERSECTION") (setq pt2 (getpoint "\n** Odaberi prvu toèku duže stranice stepenica : ")) );while (setvar "OSMODE" snap) (princ) );s
5,991
Common Lisp
.l
161
34.142857
85
0.56109
preksi/surveyors-lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
c2f632c02dde305cc44a03c1f6c8db88930a0a2bf65281f44fb315e0da05c3bd
44,178
[ -1 ]
44,179
crtanje.lsp
preksi_surveyors-lisp/crtanje.lsp
;******************************** C R T A NJ E ******************************** ;********************************* O R T O G O N A L********************************** ;***** ***** ;***** lisp za ortogonal ***** ;***** by prexy, 15.07.2001.god. ***** ;***** zadnja promjena by prexy, 15.01.2012.god. ***** ;************************************************************************************* (defun setort (/ lay stl) (setq lay "0_ortogonal") (if (tblsearch "layer" lay) (command "LAYER" "T" lay "U" lay "ON" lay "S" lay "") (progn (if (not (tblsearch "ltype" "_GEO_kontr")) (command ".linetype" "L" "_GEo_kontr" "acadiso.lin" "")) (command "LAYER" "m" lay "c" "white" "" "L" "_GEO_kontr" "" "s" "" "") ;stvaranje layera );progn );if (command "LINETYPE" "s" "BYLAYER" "") ;setiranje linetype-a (setq stl "rec") (if (tblsearch "style" stl) (setvar "textstyle" "rec") (command "STYLE" "rec" "simplex" 0 0.8 0 "N" "N" "N") ;postavljanje text stila );if );setort (defun ucsset() ;funkcija za setiranje privremenog UCS-a (command "UCS" "o" pt1) (command "UCS" "z" pt1 pt2 "") ) ;ucsset (defun nula() ;fukcija za ispis prve i zadnje apscise (ucsset) (setq ptt (list 0 (* -1 h) 0)) (command "TEXT" ptt h "-90" "0.00") (setq ptt (list linija (* -1 h) 0)) (command "TEXT" ptt h "-90" (rtos linija 2 dec)) (command "UCS" "") ;povratak u World UCS ) ;nula (defun apscisa() ;funkcija za ispis apscise (if (< (abs o) 0.001) ;ispis apscise bez ordinate (progn (setq ptt (list a (* -1 h) 0)) (command "TEXT" ptt h "-90" (strcat "%%u" (rtos a 2 dec))) ) ;progn (progn (if (< o 0) (progn (setq ptt (list a h 0)) (command "TEXT" "j" "r" ptt h "-90" (rtos a 2 dec)) ) ;progn (progn (setq ptt (list a (* -1 h) 0)) (command "TEXT" ptt h "-90" (rtos a 2 dec)) ) ;progn ) ;if ) ;progn ) ;if ) ;apscisa (defun ordinata() ;funkcija za crtanje i ispis ordinate (setvar "CELTSCALE" ( * (/ 1 (GETVAR "ltscale")) (/ m 1000.0))) (command "LINE" pt (list a 0 0) "") (command "TEXT" (list (+ a (* h 0.75)) (/ o 2) 0) h "-90" (rtos (abs o) 2 dec)) (setq mj (/ m 1000.0)) ; insertiranje simbola (if (> o 0) (progn (command "INSERT" "oo" (list a 0 0) mj mj 0) ) ;progn (progn (command "INSERT" "oo" (list a 0 0) mj mj -90 ) ) ;progn ) ;if ) ;ordinata (defun c:OR() (setvar "cmdecho" 0) ;onemogucavanje ispisa statusne linije (setvar "dimzin" 0) ;postavljanje ispisa nule iza decimalnog zareza (setq snap (getvar "OSMODE")) ;spremanje ulazne vrijednosti osnapa (setort) ;citanje postavki iz set.opi (setq opi (open "C:/VB/SET.OPI" "r")) (read-line opi) (setq m (read (read-line opi))) ;postavljanje mjerila (setq h (read (read-line opi))) ;postavljanje visine teksta (setq dec 2) ;postavljanje tocnosti ispisa iza decimalnog zareza ;definiranje linije snimanja (setq pt1 (getpoint "\nPikni 1. toèku linije snimanja:")) (setq pt2 (getpoint "\nPikni 2. toèku linije snimanja:")) (setq linija (distance pt1 pt2)) (nula) ;pozivanje funkcije za ispis prve i zadnje apscise (setq pt (getpoint "\nPikni detaljnu toèku:")) (while (/= pt nil) (setvar "OSMODE" 0) ;ukidanje osnapa (ucsset) ;pozivanje funkcije za setiranje UCS-a ;transformacija tocke iz WCS-a u UCS (setq pt (trans pt 0 1)) (setq a (car pt) o (cadr pt)) (apscisa) ;pozivanje funkcije za ispis apscise (if (> (abs o) 0.001) (ordinata) ;pozivanje funkcije za ispis ordinate ) ;if (command "UCS" "") ;povratak u World UCS (setvar "OSMODE" snap) ;vracanje osnapa na pocetnu vrijednost (setq pt (getpoint "\nPikni detaljnu toèku:")) ) ;while ) ;OR ;*********************************** O K O M I C A *********************************** ;***** ***** ;***** lisp za crtanje okomice ***** ;***** by prexy, 22.10.2002.god. ***** ;***** ***** ;************************************************************************************* ; ; nova verzija: 29.11.2004. god. - crtanje u 3D i moguænost zadavanja dužine ; (defun ucsset() ;funkcija za setiranje privremenog UCS-a (setvar "ucsicon" 0) (command "UCS" "o" pt1) (command "UCS" "z" pt1 pt2 "") ) ;ucsset (defun tocke() ;funkcija za definiranje tocaka pt1 i pt2 (setq y1 (nth 1 (assoc ' 10 ent))) ; èitanje koordinate y (setq x1 (nth 2 (assoc ' 10 ent))) ; èitanje koordinate x (setq z1 (nth 3 (assoc ' 10 ent))) ; èitanje koordinate z (setq y2 (nth 1 (assoc ' 11 ent))) ; èitanje koordinate y (setq x2 (nth 2 (assoc ' 11 ent))) ; èitanje koordinate x (setq z2 (nth 3 (assoc ' 11 ent))) ; èitanje koordinate z (setq pt1 (list y1 x1 z1)) (setq pt2 (list y2 x2 z2)) (if (< (distance pt0 pt1) (distance pt0 pt2)) (zamjena)) ) ;tocke (defun zamjena() ; funkcija koja zamjenjuje tocke pt1 i pt2 (setq pttemp pt1) (setq pt1 pt2) (setq pt2 pttemp) ) ;zamjena ;------------------------------------------------------------------------------------------ ;---------------------------------- glavna funkcija --------------------------------------- ;------------------------------------------------------------------------------------------ (defun c:ok() (setvar "cmdecho" 0) ;onemogucavanje ispisa statusne linije (setq snap (getvar "OSMODE")) ;spremanje ulazne vrijednosti osnapa (initget "d") (setq pt (getpoint "\nPikni toèku <Dužina>:")) (if (= pt "d") (setq d(getreal "\nZadaj dužinu:")) );if (while (/= pt nil) (setvar "OSMODE" 0) ;ukidanje osnapa (setq izbor(entsel "\nIzaberi liniju:")) ;selektiranje linije (setq pt0 (car(cdr izbor))) (setq ent (entget (car izbor))) (tocke) ;pozivanje funkcije za definiranje tocaka na liniji (ucsset) ;pozivanje funkcije za setiranje UCS-a (if (= d 0) (setq pt (trans pt 0 1)) ;transformacija koordinata toèke iz WCS u UCS );if (setq pt2 (trans pt2 0 1)) (setq y (nth 0 pt2)) (if (= d 0) (setq x (nth 1 pt)) (setq x d) );if (setq z (nth 2 pt2)) (setq pt3 (list y x z)) (command "line" pt2 pt3 "") (command "UCS" "") ;povratak u World UCS (setvar "ucsicon" 1) (setvar "OSMODE" snap) ;vracanje osnapa na pocetnu vrijednost (setq d 0) (initget "d u") (setq pt (getpoint "\nPikni toèku <Dužina/Undo>:")) (if (= pt "d") (setq d(getreal "\nZadaj dužinu:")) );if (if (= pt "u") (progn (entdel (entlast))(c:ok)) );if ) ;while ) ;ok ;************************** Crtanje poprecnih profila************************** ;**** **** ;**** by Prexy, 20.05.1998. **** ;**** VERZIJA 1.0 dovrsena 06.11.1999. **** ;**** **** ;****************************************************************************** (defun c:pp () (setvar "cmdecho" 0) (setvar "dimzin" 0) (command "osnap" "non") (command "style" "standard" "" 0 1 0 "N" "N" "N") (command "layer" "m" "profili" "s" "" "") (setq opi (open "c:/vb/set.opi" "r")) (read-line opi) (setq m (read (read-line opi))) (setq h (read (read-line opi))) (setq mv (read (read-line opi))) (close opi) (setq d (* h 5)) (setq n (getint "\nBroj profila <1>:")) (if (= n nil) (setq n 1)) (while (/= n 0) (setq stac (getstring "\nStacionaža:")) (setq vis (getreal "\nVisina poèetne toèke:")) (setq pt0 (getpoint "\nPoèetna toèka profila:")) (setq p 0) (setq ptt (list (nth 0 pt0) (+ (nth 1 pt0) (* 2 d)) 0)) (command "text" ptt h "270" (rtos vis 2 2)) (setq dy (getreal "\nUdaljenost:")) (while (/= dy nil) (setq dx (getreal "\nVisina:")) (setq dx (- dx vis)) (setq pt (list (+ (nth 0 pt0) dy) (+ (nth 1 pt0) (* dx (/ m mv))) 0)) (if (= p 0) (command "line" pt0 pt "") (command "line" "" pt "")) (setq p 1) (setq ptt1 (list (nth 0 pt) (nth 1 ptt) 0)) (command "text" ptt1 h "270" (rtos (+ vis dx) 2 2)) (setvar "lastpoint" pt) (setq dy (getreal "\nUdaljenost:")) ) (setq pts (list (/ (+ (nth 0 pt0) (nth 0 pt)) 2) (+ (nth 1 ptt) (* 2 d)) 0)) (setq ptn (list (nth 0 pts) (+ (nth 1 pts) (* h 3)) 0)) (command "text" "j" "c" pts (* h 1.5) "0" stac) (command "text" "j" "c" ptn (* 2 h) "0" (strcat "Profil " (rtos n 2 0))) (setq nn (+ n 1)) (setq n (getint (strcat "\nBroj profila <" (rtos nn 2 0) ">:"))) (if (= n nil) (setq n nn)) ) (setvar "cmdecho" 1) ) ;*********************************** P I K A ********************************** ;***** ***** ;***** lisp za crtanje pika ***** ;***** by prexy, 13.01.2012.god. ***** ;***** ***** ;************************************************************************************* (defun c:pika() (setvar "cmdecho" 0) (setq opi (open "c:/vb/set.opi" "r")) (read-line opi) (setq mjerilo (read-line opi)) (prompt (strcat "Mjerilo je 1:" mjerilo)) (setq pnt (getpoint "\n**Izaberi mjesto za piku:")) ;(setq fr (cdr (assoc 70 (dictsearch (namedobjdict) "ACAD_WIPEOUT_VARS")))) ;(if (= fr 1) (command "wipeout" "f" "off")) (command "wipeout" "f" "off") (setq mj (/ (read mjerilo) 1000.0)) (while (/= pnt nil) (command "_insert" "s_medja_neob.dwg" pnt mj mj 0) (setq pnt (getpoint "\n**Izaberi mjesto za piku:")) );while )
9,982
Common Lisp
.l
252
36.706349
103
0.495896
preksi/surveyors-lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
3e81502de967e39b1c2d6bc39612e3e34cc881ea82520ff1ef497a3c605f2f24
44,179
[ -1 ]
44,180
alati.lsp
preksi_surveyors-lisp/alati.lsp
;******************************** S T A T I S T I K A ****************************** ;***** ***** ;***** lisp za ispis statistike dwg-a ***** ;***** by prexy, 29.10.2002.god. ***** ;***** ***** ;************************************************************************************* (defun space (prostor duzina) ;funkcija koja ispisuje "prostor - duzina" space-ova (setq i (- prostor duzina)) (while (/= i 0) (princ " " f) (setq i (- i 1)) );while );space (defun tablica (ime) ;funkcija koja racuna broj elemenata u tablici (setq tab (tblnext ime T)) (setq broj 0) (while tab (setq broj (+ broj 1)) (setq tab (tblnext ime)) );while ;(if (= ime "block") (setq broj (- broj 1))) (princ (itoa broj)) );tablica (defun opca_stat() (princ (strcat "\n Ime datoteke: " (getvar "DWGPREFIX") (getvar "DWGNAME")) f) (setq objekti (ssget "X")) (princ (strcat "\n Broj objekata: " (itoa (sslength objekti))) f) (princ (strcat "\n Broj layera: " (tablica "layer")) f) (princ (strcat "\n Broj def. blokova: " (tablica "block")) f) );opca_stat (defun lejer() (setq n 0) (princ "\n Red.br Ime layera Boja Linija" f) (princ "\n---------------------------------------------------------" f) (setq lay (tblnext "layer" T)) (while lay (setq n (+ n 1)) (princ "\n " f) (princ (itoa n) f) (space 6 (strlen (itoa n)))(princ (cdr (assoc '2 lay)) f) (space 33 (strlen (cdr (assoc '2 lay))))(princ (abs (cdr (assoc '62 lay))) f) (space 5 (strlen (itoa (abs (cdr (assoc '62 lay))))))(princ (cdr (assoc '6 lay)) f) (setq lay (tblnext "layer")) );while ) (defun c:stt () (setvar "cmdecho" 0) (setq imeDat (strcat (getvar "dwgprefix") (getvar "dwgname") "_stat.txt")) (setq dat imeDat) (setq f (open dat "w")) (opca_stat) ;opca statistika (princ "\n" f)(princ "\n" f) (lejer) ;statistika layera (close f) (initget "m d") (setq opcija (getkword "\nIspis na Monitor/Datoteku <Monitor>:")) (if (= opcija "d") (command "shell" (strcat "notepad " dat)) ;ispis u datoteku (progn ;ispis na monitor (setq ff (open imeDat "r")) (setq linija T) (while linija (princ "\n") (princ (setq linija (read-line ff))) );while (close ff) (command "shell" (strcat "del " imeDat)) ;brisanje datoteke (textpage) (setvar "cmdecho" 1) (princ) ) ) ) ;************************ L A Y E R C H A N G E ********************** ;***** ***** ;***** Lisp za promjenu Layer-a (broja, toèke i visine) u željeni layer ***** ;***** by DARKO ***** ;***** ***** ;************************************************************************************* (defun C:ll() (progn (setq elem1 (ssget) brelem (sslength elem1) brojac (1- brelem) new (getstring "Novi layer:") lnew (tblsearch "layer" new) tip (cdr (cadr lnew)) tip2 (substr tip 3) );setq );progn (setq a 0) (while (<= a brojac) (setq name (ssname elem1 a)) (setq nname (entget name)) (setq code (cdr(assoc 8 nname))) (setq code1 (substr code 1 2)) (setq code1 (strcat code1 tip2)) (setq codde (assoc 8 nname)) (setq code1 (cons 8 code1)) (setq nname(subst code1 codde nname)) (entmod nname) (setq a (1+ a)) );while (princ) );end ll ;************************************************************************************* ;***************** Lisp za postavljanje objekata na zadanu visinu ***************** ;***************** ili promjenu visine za zadani pomak ***************** ;***************** verzija 1.1 ***************** ;***************** by prexy, 22.05.2002. ***************** ;************************************************************************************* ; Funkcije za postavljanje pojedinih vrsta objekata na visinu z ;----------------------------------2D poli------------------------------------------------- (defun 2dpoli0() ; funkcija za postavljanje 2d polilinije na visinu z (if (= tip "Relativni") (progn (setq h (cdr (assoc ' 38 (entget ent)))) ; èitanje visine objekta (setq visina (+ h pomak)) ); progn ); if (setq ent ; zamjena visine 2d polilinije (subst (cons 38 visina) (assoc ' 38 (entget ent)) (entget ent)) ) ; promjena visine objekta (entmod ent) ) ;--------------------------------polilinija------------------------------------------------- (defun poli0() ; funkcija za postavljanje 3d polilinije na visinu z (setq entpoli ent) ; èuvanje varijable polyline entity (setq ent (entnext entpoli)) (setq podvrsta (cdr (assoc 0 (entget ent)))) ; èitanje vrste objekta (while (= podvrsta "VERTEX") (tocka0) ; postavljanje èvorova polilinije na visinu (setq ent (entnext (cdr (assoc -1 ent)))) ; pomicanje na iduæi èvor (setq podvrsta (cdr (assoc 0 (entget ent)))) ; èitanje vrste objekta ); while ; update prikaza polilinije (entupd entpoli) ) ;----------------------------------linija-------------------------------------------------- (defun linija0() ; funkcija za postavljanje linije na visinu z (tocka0) ; pomak prve toèke linije svodi se na pomak toèke (if (= tip "Relativni") (progn (setq h (nth 3 (assoc ' 11 ent))) ; èitanje visine objekta (setq visina (+ h pomak)) ); progn ); if (setq y (nth 1 (assoc ' 11 ent))) ; èitanje koordinate y (setq x (nth 2 (assoc ' 11 ent))) ; èitanje koordinate x (setq ent ; zamjena visine druge toèke linije (subst (list 11 y x visina) (assoc ' 11 ent) ent) ) ; promjena visine objekta (entmod ent) ) ;-----------------------------------tocka0-------------------------------------------------- (defun tocka0() ; funkcija za postavljanje toèkastih objekata (toèka, tekst, blok) na visinu z (if (= tip "Relativni") (progn (setq h (nth 3 (assoc ' 10 (entget ent)))) ; èitanje visine objekta (setq visina (+ h pomak)) ); progn ); if (setq y (nth 1 (assoc ' 10 (entget ent)))) ; èitanje koordinate y (setq x (nth 2 (assoc ' 10 (entget ent)))) ; èitanje koordinate x (setq ent ; zamjena visine toèkastog objekta (subst (list 10 y x visina) (assoc ' 10 (entget ent)) (entget ent)) ) ; promjena visine objekta (entmod ent) ) ;------------------------------------------------------------------------------------------ ;---------------------------------- glavna funkcija --------------------------------------- ;------------------------------------------------------------------------------------------ (defun c:vv () (setvar "cmdecho" 0) (command "osnap" "non") (setq i 0) (initget "Apsolutni Relativni") ; izbor vrste pomaka (setq tip (getkword "\nVrsta pomaka (Apsolutni/Relativni) <Apsolutni>:")) (if (= tip nil) (setq tip "Apsolutni")) (if (= tip "Apsolutni") (setq visina (getreal "Nova visina:")) (setq pomak (getreal "Razlika visine:")) ); if (setq objekti (ssget)) ; selektiranje objekata (repeat (sslength objekti) (setq ent (ssname objekti i)) ; dodjeljivanje objekta iz sset-a varijabli (setq vrsta (cdr (assoc 0 (entget ent)))) ; èitanje vrste objekta ; filtriranje objekata (if (= vrsta "LWPOLYLINE") (2dpoli0)) (if (= vrsta "POLYLINE") (poli0)) (if (= vrsta "LINE") (linija0)) (if (= vrsta "POINT") (tocka0)) (if (= vrsta "TEXT") (tocka0)) (if (= vrsta "MTEXT") (tocka0)) (if (= vrsta "INSERT") (tocka0)) (if (= vrsta "ARC") (tocka0)) (if (= vrsta "CIRCLE") (tocka0)) (princ (strcat "\r " (rtos (+ i 1) 2 0))) ; ispis broja objekta (setq i (+ i 1)) ); repeat (setvar "cmdecho" 1) (princ) )
8,110
Common Lisp
.l
215
34.576744
92
0.490143
preksi/surveyors-lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
1d307c1aaa325a4c506fca0d390127e99164ac0394ba52b6254193707019e591
44,180
[ -1 ]
44,181
blokovi.lsp
preksi_surveyors-lisp/blokovi.lsp
;******************************************************* ;******************************************************* ; Lisp za reinsertiranje bloka ; izborom vec postojeceg bloka na dwg-u ; by prexy, 04.02.2001. ;******************************************************* ;******************************************************* (defun C:RI () (setq blok (entsel "\nSelektiraj blok")) (if blok (progn (setq bl (entget (car blok))) (if (= (cdr (assoc 0 bl)) "INSERT") (progn (setq blok2 (cdr (assoc 2 bl))) (setq blscale (cdr (assoc 41 bl))) (setq pt (getpoint "\nInsertna toèka:")) (command "INSERT" blok2 pt blscale blscale) );progn (alert "Selektirani objekt nije blok! ") );if );progn (princ "\nPromašaj!") );if (princ) );RI ;************************************************************************************* ; BX by prexy 24.04.2000, zadnja promjena 14.01.2012. ; sve instance nekog bloka unutar dwg-a zamjenjuju se drugim dwg blokom ;************************************************************************************* (defun C:BX() (setq bldef (entsel "Selektiraj blok:")) (setq e (entget (car bldef))) (setq bln (cdr (assoc 2 e))) (setq ss1 (ssget "x" (list (assoc 2 e)))) (setq putanja "g:/simboli") (if (= (findfile putanja) nil) (setq putanja (getvar "DWGPREFIX")) (setq putanja (strcat putanja "/")) );if (setq wf (getfiled "Izbor datoteke" putanja "DWG" 8)) (if (= wf nil) (quit)) (COMMAND "INSERT" wf "0,0" 1 "" 0 "") (setq ee (entget (entlast))) (entdel (entlast)) (setq i 0) (repeat (sslength ss1) (setq ent (ssname ss1 i)) (setq ed (entget ent)) (setq ed (subst (assoc 2 ee) (assoc 2 ed) ed)) (entmod ed) (setq i (+ i 1)) ) (COMMAND "PURGE" "B" BLN "N") );BX ;************************************************************************************* ; RB by prexy, 24.04.2000. ; svi izabrani blokovi rotiraju se za zadani kut ;************************************************************************************* (defun C:RB (/ e f inspt sca ss cmde) (setvar "CMDECHO" 0) (setq ss (ssget)) (print) (setq sca (getreal "Rotacija: ")) (setq c 0) (if ss (setq e (ssname ss c))) (while e (setq f (entget e)) (setq inspt (cdr (assoc 10 f))) (COMMAND "ROTATE" e "" inspt sca) (PRINC ".") (setq c (1+ c)) (setq e (ssname ss c)) ) (setvar "CMDECHO" 1) (princ) );RB ;************************************************************************************* ; SB by prexy, 24.04.2000. ; svi izabrani blokovi skaliraju se za zadano mjerilo (scalefactor) ;************************************************************************************* (defun C:SB (/ e f inspt sca ss cmde) (setvar "CMDECHO" 0) (setq ss (ssget)) (print) (setq sca (getreal "Mjerilo: ")) (setq c 0) (if ss (setq e (ssname ss c))) (while e (setq f (entget e)) (setq inspt (cdr (assoc 10 f))) (COMMAND "SCALE" e "" inspt sca) (PRINC ".") (setq c (1+ c)) (setq e (ssname ss c)) ) (setvar "CMDECHO" 1) (princ) );SB
3,200
Common Lisp
.l
99
29.242424
86
0.448613
preksi/surveyors-lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
3c2fa979297555fa38fbb306f99e4d456edafb5865d9c36f9bc72d26d21e89a3
44,181
[ -1 ]
44,202
tournament.lisp
nshan651_rcv/src/tournament.lisp
;;;; Ranked choice voting (in-package #:cl-user) (defpackage #:rcv/tournament (:use #:cl) (:export :display-results :tournament)) (in-package #:rcv/tournament) (defun rank-prefs (top-choices) "Return the rankings of each ballot's top choice candidates." (let ((ranking '())) (dolist (choice top-choices) ;; Add a new cons pair if the key doesn't already exist. (pushnew (cons choice 0) ranking :key #'(lambda (x) (equal (car x) choice))) ;; Increment the cons cdr (let ((existing (assoc choice ranking :test #'equal))) (setf (cdr existing) (1+ (cdr existing))))) (sort ranking #'(lambda (a b) (< (cdr a) (cdr b)))))) (defun eliminate (rankings ballots) "Eliminate the candidate with the fewest votes from the ballot." ;;; TODO: Handle ties!!! (let ((candidate (caar rankings))) (mapcar (lambda (ballot) (remove-if (lambda (c) (string= c candidate)) ballot)) ballots))) (defun add-eliminated (rankings candidates) "Add eliminated candidates to current round history with a vote count of zero." (dolist (candidate candidates) (pushnew (cons candidate 0) rankings :key #'(lambda (x) (equal (car x) candidate)))) (list rankings)) (defun find-majority-winners (rankings seats) "Check for majority winner(s) in the rankings." (let* ((total-votes (reduce #'+ rankings :key #'cdr)) ;; Use the droop quote formula. (threshold (1+ (/ total-votes (1+ seats))))) (format t "THRESHOLD: ~A~%" threshold) (remove-if #'(lambda (x) (< (cdr x) threshold)) rankings))) (defun update-rhist (rankings candidates ranking-history) "Add a new entry to the ranking history including previously eliminated candidates." (append ranking-history (add-eliminated rankings candidates))) (defun tournament (ballots candidates seats &optional elected-candidates ranking-history) "Tournament round." (let* ((top-choices (mapcar #'car ballots)) (rankings (rank-prefs top-choices)) (rhist (update-rhist rankings election))) (let* ((elected (find-majority-winners rankings seats)) (remaining-candidates (remove-if #'(lambda (x) (member x elected)) rankings))) (format t "ELECTED: ~A~%" elected) (format t "REMAINING: ~A~%" remaining-candidates) ;; (if (and elected (= seats (length elected))) (if (or (= 5 (length rhist)) (and elected (= seats (length elected)))) ;; Terminal case: print end results and/or return ranking hist (progn (display-results rhist) rhist) ;; Move to next tourn round; eliminating last place candidates (tournament (eliminate remaining-candidates ballots) candidates seats elected rhist)))))
2,718
Common Lisp
.lisp
66
36.575758
89
0.677005
nshan651/rcv
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
f1e5c138d0e0da270b7ae4a90d79d69e59bdec8ee3e865b040df0392cbe72a41
44,202
[ -1 ]
44,203
election.lisp
nshan651_rcv/src/election.lisp
(in-package #:cl-user) (defpackage #:rcv/election (:use #:cl #:cl-csv) (:export :get-ballots :get-candidates)) (in-package #:rcv/election) (defun get-ballots (source) "Read ballots from stdin or a file." (let ((csv-str (if (and source (probe-file source)) (parse-namestring source) (with-output-to-string (output) (loop for line = (read-line *standard-input* nil) while line do (write-line line output)))))) (remove-empty (cl-csv:read-csv csv-str)))) (defun get-candidates (ballots) "Get a list of candidates, derived from the submitted ballots." (remove-duplicates (reduce #'append ballots :key #'identity) :test #'equal)) (defun remove-empty (ballots) "Remove nil values and empty strings from ballots." (mapcar #'(lambda (ballot) (remove-if #'(lambda (x) (or (null x) (string= x ""))) ballot)) ballots)) (defun compute-quota (ballots seats) (multiple-value-bind (quotient) (floor (1+ (/ (length ballots) (1+ seats)))) quotient)) (defun add-party (candidates) "Get a mapping of the candidate and their respective party." (mapcar #'(lambda (c) (cons c 'Unkown)) candidates)) (defun display-results (ranking-history) "Print out the ranking history." (let ((round-nbr 0)) (dolist (round ranking-history) (format t "Round ~a~%" (incf round-nbr)) (format t "Candidate Votes ------------------------------ ---------~%") (dolist (rankpair (reverse round)) (let* ((candidate (car rankpair)) (votes (cdr rankpair)) (hspace-col1 (- 32 (length candidate))) ;; (hspace-col2 (- 10 (length (format nil "~d" votes)))) ) (format t "~a~vA~a~%" candidate hspace-col1 #\Space votes))) (format t "~%")))) (defun election-context (candidates seats quota) "Closure encapsulating an election quota." (lambda (f) (funcall f candidates seats quota))) (defun example-function (election-context) "Example function using the encapsulated data." (election-context #'(lambda (candidates seats quota) (format t "Candidates: ~a~%Seats: ~a~%Quota: ~a~%" candidates seats quota)))) (let ((election (election-context 69 420 666))) (example-function election)) ;; (defstruct (election (:constructor make-election ;; (ballots &optional number-of-seats ;; &aux (candidates (get-candidates ballots)) ;; (seats (or number-of-seats 1)) ;; (quota (compute-quota ballots seats))))) ;; (candidates :read-only) ;; (seats :read-only :type integer) ;; (quota :read-only :type integer) ;; ranking-history) ;; (let ((e (make-election "../data/3-seat.csv"))) ;; election-ballots e)
2,749
Common Lisp
.lisp
67
36.164179
83
0.630101
nshan651/rcv
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
20be303f63781435f06affdd6a45de2c0c16738be3cefa6b873cf0ee47ad5e6e
44,203
[ -1 ]
44,204
rcv.lisp
nshan651_rcv/src/rcv.lisp
;;;; Ranked choice voting. ;;;; https://en.wikipedia.org/wiki/Instant-runoff_voting ;;;; Python project for IRV: https://github.com/jontingvold/pyrankvote (in-package #:cl-user) (defpackage #:rcv (:use #:cl #:clingon) (:import-from :rcv/tournament :tournament) (:import-from :rcv/election ;; :election :get-ballots ) (:export :main :rcv)) (in-package #:rcv) (defun rcv (source seats) "Ranked choice voting. 1. Eliminate the candidate with the fewest votes. 2. If only one candidate remains, elect this candidate and stop. 3. Otherwise, go back to 1." (let* ((ballots (rcv/election:get-ballots source)) (candidates (rcv/election:get-candidates ballots))) (tournament ballots candidates))) (defun cli/handler (cmd) "Command-line argument handler which enters rcv." (let ((args (clingon:command-arguments cmd)) (seats (parse-integer (clingon:getopt cmd :seats)))) (rcv (car args) seats))) (defun cli/options () "A list of cli options." (list (clingon:make-option :string :description "Specify a mapping of eligible candidates and their affiliated parties. By default, rcv will use the set of all candidates in the ballot." :short-name #\c :long-name "candidates" :key :candidates) (clingon:make-option :string :description "Specify how many seats (winners) the election will have." :short-name #\n :long-name "number-of-seats" :initial-value '1 :key :seats) (clingon:make-option :flag :description "Instant runoff vote." :long-name "irv" :key :irv) (clingon:make-option :flag :description "Minimax vote." :long-name "minimax" :key :minimax) (clingon:make-option :flag :description "Preferential block vote" :long-name "pbv" :key :pbv) (clingon:make-option :flag :description "Single transferable vote." :long-name "stv" :key :stv))) (defun cli/command () "Command-line entrypoint." (clingon:make-command :name "rcv" :description "Ranked choice voting." :version "0.1" :authors '("nshan651 <[email protected]") :license "GPL-3.0" :options (cli/options) :handler #'cli/handler)) (defun main () "Program entrypoint." (clingon:run (cli/command)))
2,245
Common Lisp
.lisp
76
25.868421
155
0.692557
nshan651/rcv
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
120a426a4b0623a6522d752c96354750f2cbf6f33f60a8bea04da47ee19af647
44,204
[ -1 ]
44,205
main.lisp
nshan651_rcv/t/main.lisp
(in-package #:cl-user) (defpackage #:rcv/t/main (:use #:cl #:fiveam #:rcv/stdin #:rcv/tournament)) (in-package #:rcv/t/main) (def-suite test-rcv :description "Test rank choice voting.") (in-suite test-rcv) (defvar *ballots-str* '(("Bush" "Nader" "Gore") ("Bush" "Nader" "Gore") ("Bush" "Nader") ("Bush" "Nader") ("Nader" "Gore" "Bush") ("Nader" "Gore") ("Gore" "Nader" "Bush") ("Gore" "Nader") ("Gore" "Nader" "Yeet")) "Define a nested list of ballots of type string.") (defvar *ballots-sym* '((Bush Nader Gore) (Bush Nader Gore) (Bush Nader) (Bush Nader) (Nader Gore Bush) (Nader Gore) (Gore Nader Bush) (Gore Nader) (Gore Nader Yeet)) "Define a nested list of ballots of type symbol.") (defvar *ballots-f* (rcv/stdin:get-ballots "./data/ballots.csv") "Read a nested list of ballots from a file.") (defvar *candidates* (rcv/stdin:get-candidates *ballots-f*) "Obtain a list of eligible candidates, derived from the ballots.") (fiveam:test irv-1 (let ((res (tournament *ballots-f* *candidates* 1))) (fiveam:is (equal res '((("Yeet" . 0) ("Nader" . 2) ("Gore" . 3) ("Bush" . 4)) (("Yeet" . 0) ("Nader" . 0) ("Bush" . 4) ("Gore" . 5))))))) (fiveam:run!)
1,275
Common Lisp
.lisp
45
24.577778
68
0.60834
nshan651/rcv
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
f70b58c79eb79c5de0f73f98bab5d79f6bbe424bc26d1b017c74e7ada80ddb2b
44,205
[ -1 ]
44,206
rcv.asd
nshan651_rcv/rcv.asd
(defsystem "rcv" :author "nshan651 <public.nshan651.com>" :license "AGPL 3.0" :version "0.1" :homepage "https://github.com/nshan651/rcv" :bug-tracker "https://github.com/nshan651/rcv/issues" :source-control (:git "[email protected]/nshan651/rcv.git") :description "Ranked-choice voting command-line tool." :depends-on ("clingon" "cl-csv" "uiop") ;; Needed for pre-configuring default cli options. :defsystem-depends-on (:clingon) :components ((:module "src" :serial t :components ( (:file "election") (:file "tournament") (:file "rcv") ))) :long-description #.(uiop:read-file-string (uiop:subpathname *load-pathname* "README.md")) :in-order-to ((test-op (test-op "rcv/tests"))) :build-operation "program-op" :build-pathname "bin/rcv" :entry-point "rcv::main") (defsystem "rcv/tests" :description "Test suite for rcv." :author "Nick Shannon <public.nshan651.com>" :license "AGPL 3.0" :version "0.1" :depends-on ("rcv" "fiveam") :components ((:module "t" :serial t :components ((:file "main") ) )) ;; :perform (test-op (op c) (symbol-call :rove :run c))) ) ;;; Customize default options for clingon. ;;; Add -h and -v as shorthands by updating default options. (setf clingon:*default-options* (list (clingon:make-option :flag :description "Display usage information and exit." :long-name "help" :short-name #\h :key :clingon.help.flag) (clingon:make-option :flag :description "Display version and exit." :long-name "version" :short-name #\v :key :clingon.version.flag) clingon:*default-bash-completions-flag*)) ;;; Enable SBCL core compression to greatly reduce binary size. #+sb-core-compression (defmethod asdf:perform ((o asdf:image-op) (c asdf:system)) (uiop:dump-image (asdf:output-file o c) :executable t :compression t))
1,979
Common Lisp
.asd
62
26.790323
63
0.646259
nshan651/rcv
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
ed2da9f65071f1c46cdad00acfd2b0632cb0444522af40e20f4361b4a2ce6ecc
44,206
[ -1 ]
44,208
Makefile
nshan651_rcv/Makefile
# Binary executable BIN := rcv # Lisp implementation (default to sbcl). LISP := sbcl .PHONY: all clean install run uninstall all: $(LISP) --non-interactive \ --eval '(ql:quickload :rcv)' \ --eval '(asdf:make :rcv)' run: @ ./bin/$(BIN) test: $(LISP) --non-interactive --eval '(ql:quickload :rcv/tests)' install: mkdir -p $(DESTDIR)/usr/local/bin install -Dm755 ./bin/$(BIN) $(DESTDIR)/usr/local/bin/$(BIN) uninstall: rm -f $(DESTDIR)/usr/local/bin/$(BIN) clean: uninstall rm -f ./bin/$(BIN)
510
Common Lisp
.l
20
23.5
62
0.677019
nshan651/rcv
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
f9e9520db07f2e9014050d4a7f3b7ec0af9b326caf44ba1debd857abe4c3e677
44,208
[ -1 ]
44,227
main.lisp
lambdanil_not-clos/main.lisp
(load "not-clos.lisp") (not-clos:make-object person ;; Create a new object person ;; The slots of this object ((name "unnamed") ;; We can set an initialization form for slot year (language (error "make-person: Missing required :name key")))) ;; initforms are lazily evaluated ;; Define a method; will be defined as <object name>-<method name> (person-defmethod incf-year () ;; person-incf-year in this case (incf self-year)) ;; accessible as self-<slot> inside methods for comfort ;; You can still use (person-set self year <x>) (person-defmethod make-younger () (person-incf-year not-clos:self) ;; we can pass self to another method (format t "Person ~a has just become younger!~%" self-name)) (person-defmethod return-self () (not-clos:self)) ;; the not-clos:self symbol evaluates to nil when not passed to self method, ;; so when passing self to foreign function (not this object's method) we have to evaluate (self) first (person-defmethod calculate-age () (- 2023 self-year)) ;; values are returned from methods as you'd expect (defvar my-person (make-person :year 1998 :language "English")) ;; create a new person, name is going to be equal to initform "unnamed" (person-set my-person name "Mary") ;; person-set macro to change existing value (format t "Our person just got a name, her name is ~a!~%" (person-get my-person name)) ;; person-get macro to get value (person-make-younger my-person) (format t "Her age is ~a.~%" (person-calculate-age my-person)) (format t "She is a ~a.~%" (not-clos:object-type my-person)) (write person-slots) ;; We can also list an object's slots (terpri) (person-defmethod print-name () (format t "~a~%" self-name)) (defvar *db* nil) (defun add-db (person) (setf *db* (cons person *db*))) (add-db (make-person :name "John" :year 1990 :language "Scheme")) (add-db (make-person :name "Mary" :year 1995 :language "Haskell")) (add-db (make-person :name "Ann" :year 1993 :language "Scheme")) (add-db (make-person :name "Paul" :year 2000 :language "Python")) (add-db (make-person :name "Amy" :year 2004 :language "C")) ;; Find all people born before 2000 who like Scheme and print their names (mapcar (lambda (person) (person-print-name person)) (not-clos:where *db* ((year < 2000) ;; using the where macro (language string= "Scheme"))))
2,452
Common Lisp
.lisp
40
55.825
139
0.67375
lambdanil/not-clos
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
df49f4319c2d82ba3efd5a59971c1115863cd3f03681f83746215f343375ba61
44,227
[ -1 ]
44,228
not-clos.lisp
lambdanil_not-clos/not-clos.lisp
(defpackage :not-clos (:use :cl) (:nicknames :nclos) (:export #:where #:make-object #:object-type #:self)) (in-package :not-clos) ;; Make the object slots (symbol-name (car ;; '(<object>-slot <object>-slot0) (defmacro make-slots (object) (let ((slots (symbol-append object '- 'slots))) `(mapcar (lambda (slot) (symbol-append (quote ,object) '- slot)) ,slots))) ;; Make self-referencing slots ;; '(self-slot self-slot0) (defmacro make-slots-self (object) (let ((slots (symbol-append object '- 'slots))) `(mapcar (lambda (slot) (symbol-append 'self '- slot)) ,slots))) ;; Append multiple symbols, abused for macros (defun symbol-append (&rest symbols) (intern (apply #'concatenate 'string (mapcar #'symbol-name symbols)))) ;; Get type of object (defun object-type (obj) (cdr (assoc 'obj/type obj))) ;; Allow applying 'and macro on a list ;; a little ugly (defun unwrap-and (&rest conds) (eval `(and ,@conds))) ;; Create test string for the where macro (defmacro make-tests (item keys) `(apply #'unwrap-and (mapcar (lambda (key) (funcall (if (> (length key) 2) (cadr key) #'=) (cdr (assoc (car key) ,item)) (caddr key))) ,keys))) ;; Create a list of '((self-slot nil) (self-slot0 nil)) from '(slot slot0) (defun map-slots (object-name slots) (double-mapcar (lambda (slot value) (cons slot (list value))) (mapcar (lambda (slot) (symbol-append 'self '- slot)) slots) (mapcar (lambda (slot) nil) slots))) ;; Same as above but initializes values to match associated object; used for let bindings ;; '((self-slot) (cdr (assoc 'slot self))) (defun map-slots1 (object-name slots) (double-mapcar (lambda (slot value) (cons slot (list value))) (mapcar (lambda (slot) (symbol-append 'self '- slot)) slots) (mapcar (lambda (slot) `(cdr (assoc (quote ,slot) self/internal))) slots))) ;; Generates setf list ;; '((setf self-slot (cdr (assoc 'slot self))) ;; (setf self-slot0 (cdr (assoc 'slot0 self)))) (defun map-slots2 (object-name slots) (double-mapcar (lambda (slot value) `(setf ,slot ,value)) (mapcar (lambda (slot) (symbol-append 'self '- slot)) slots) (mapcar (lambda (slot) `(cdr (assoc (quote ,slot) (car self/internal)))) slots))) ;; Find objects by key conditions in object list ;; (where list ((value1 > 2000) ;; (value2 string= "test"))) (defmacro where (list keys &key test) `(remove-if-not (lambda (item) (make-tests item (quote ,keys))) ,list)) ;; Map to 2 lists and return a merge ;; (double-mapcar (lambda (first second)) first second) (defun double-mapcar (func list1 list2 &key accum1) (if list1 (double-mapcar func (cdr list1) (cdr list2) :accum1 (cons (funcall func (car list1) (car list2)) accum1)) (reverse accum1))) (defun extract-keys (list) (mapcar #'(lambda (item) (if (consp item) (car item) item)) list)) ;; Object creation macro (defmacro make-object (name init-keys) (let* ((keys (extract-keys init-keys)) (slots (map-slots name keys)) (object-slots (symbol-append name '- 'slots)) (self-slots `(cons (cons 'cons (cons ''obj/type (list '(quote ,name)))) (mapcar (lambda (slot) (cons 'cons (cons `(quote ,slot) (list (symbol-append 'self '- slot))))) ,object-slots)))) `(progn ;; obj/type defines the type as a symbol ;; make-<object> (defun ,(symbol-append 'make '- name) (&key ,@keys) (cons (cons 'obj/type (quote ,name)) (double-mapcar (lambda (key other-key) (let* ((key-p (consp key)) (extracted-key (if key-p (car key) key))) (if other-key (cons extracted-key other-key) ;; when key is supplied (cons extracted-key ;; when not supplied (if key-p (eval (cadr key)) nil))))) ;; ensure the initform is evaluated (quote ,init-keys) (list ,@keys)))) ;; Create <object>-slots as well as its function (defvar ,object-slots (quote ,keys)) (defun ,object-slots () (quote ,keys)) ;; modify-self macro; sets self- variables to returned value; for internal use ;; should only be used with matching methods ;;obj/<object>-modify-self (defmacro ,(symbol-append 'obj/ name '-modify-self) (&rest body) `(let* ((self/internal (progn ,@body))) ,@(map-slots2 (quote ,name) ,object-slots) self/internal)) ;; <object>-defmethod ;; Creates an internal function and an invoker macro ;; The invoker macro wraps around the function and applies its return values, ;; either over the object which was invoked or 'self if inside method. ;;<object>-defmethod (defmacro ,(symbol-append name '- 'defmethod) (method-name args &rest body) `(progn ;; Internal method function ;; Wraps around the method body; assigns 'self- variables with a let*, ;; assigns the (self) macro. ;; (self) produces an object from the local 'self- variables ;;obj/<object>-<method-name>-intern (self args) (defun ,(symbol-append 'obj/ (quote ,name) '- method-name '-intern) ,(cons 'self/internal args) (macrolet ((self () '(list ,@,self-slots))) ;; (self) macro ;; bind self to this package so symbol comparisons work (let* ,(cons '(self nil) (map-slots1 (quote ,name) ,object-slots)) ;; 'self-* bindings (let ((res/internal (progn ,@body))) ;; call (self) to return new object ;; We also pass the return value of the function ;; Since it's not possible to cons a nil we send back a special 'obj/nil symbol, ;; which is then checked by the wrapper to return nil when necessary. `(,(self) . ,(if res/internal res/internal 'obj/nil)))))) ;; Invoker macro ;;<object>-<method-name> (obj &rest args) (defmacro ,(symbol-append (quote ,name) '- method-name) (obj &rest args) (if (not (eq obj 'self)) ;; Check the 'self special case ;; Wrap with standard setf `(let ((obj/result (,(symbol-append 'obj/ (quote ,(quote ,name)) '- (quote ,method-name) '- 'intern) ,obj ,@args))) (setf ,obj (car obj/result)) ;;(car obj/result)) (if (eq (cdr obj/result) 'obj/nil) nil (cdr obj/result))) ;; Wrap with modify-self (when 'self is used) `(let ((res (cdr (,(symbol-append 'obj/ (quote ,(quote ,name)) '-modify-self) (,(symbol-append 'obj/ (quote ,(quote ,name)) '- (quote ,method-name) '- 'intern) (self) ,@args))))) (if (eq res 'obj/nil) nil res)))))) ;; Define internal setter functions by mapping over defined slots. ;;<object>-set-<var>-intern (mapcar (lambda (var) (eval `(,(symbol-append (quote ,name) '- 'defmethod) ;; ugly eval hack! ,(symbol-append 'set '- var '- 'intern) (,var) (setf ,(symbol-append 'self '- var) ,var)))) ,object-slots) ;; Create a setter macro which invokes the appropriate internal function. ;;<object>-set (defmacro ,(symbol-append name '- 'set) (,name var val) `(,(symbol-append (quote ,name) '- 'set '- var '- 'intern) ,,name ,val)) ;; Define internal getter functions by mapping over defined slots. ;;<object>-get-<var>-intern (mapcar (lambda (var) (eval `(,(symbol-append (quote ,name) '- 'defmethod) ;; ugly eval hack again! ,(symbol-append 'get '- var '- 'intern) () ,(symbol-append 'self '- var)))) ,object-slots) ;; Create a setter macro which invokes the appropriate internal function. ;;<object>-set (defmacro ,(symbol-append name '- 'get) (,name var) `(,(symbol-append (quote ,name) '- 'get '- var '- 'intern) ,,name)))))
7,629
Common Lisp
.lisp
164
41.371951
106
0.632244
lambdanil/not-clos
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
3cb11e74634005556b69418462bb7f82560c25bba6ceb25b49c40e31f04e98a4
44,228
[ -1 ]
44,247
macrolayer.lisp
equwal_defsl/macrolayer.lisp
;;; This file is meant to provide a macro layer for Sly and Slime ;;; This contains a few things: ;;; - 5AM is used for testing, but only if it is a *features* member. ;;; The abstraction gets more specific as you go to the end of the file. (in-package :sl) #+5am (defmacro show-bound (unbind predicate thing &body body) `(progn (,unbind ',thing) ,@body (,predicate ',thing))) #+5am (defmacro show-boundfn (fn &body body) `(show-bound fmakunbound fboundp ,fn ,@body)) #+5am (defmacro show-boundvar (var &body body) `(show-bound makunbound boundp ,var ,@body)) #+5am (select-preference 'fboundp '(("SLYNK" "OPERATOR-ARGLIST"))) (defmacro defweak-strings (namespace boundp sl-name &rest qualified-names) "Make a weak definition, based on preferences. Probably should use wrapper functions instead of this one, as it takes string arguments." (with-gensyms (symname package new-namespace) `(let (,new-namespace) (setf (symbol-function ',new-namespace) (symbol-function ',namespace)) (multiple-value-bind (,symname ,package) (select-preference ',boundp ',(group qualified-names 2)) (setf (symbol-function (intern ,symname)) (funcall (symbol-function ',new-namespace) (intern ,symname ,package))))))) #+5am (show-boundfn operator-arglist (defweak-strings symbol-function fboundp "OPERATOR-ARGLIST" "SWANK" "OPERATOR-ARGLIST" "SLYNK" "OPERATOR-ARGLIST")) (defmacro defweak (namespace boundp sl-name &rest qualified-names) "Symbol wrapper for defweak-strings." `(defweak-strings ,namespace ,boundp ,(symbol-name sl-name) ,@(loop for q in qualified-names collect (symbol-name q)))) #+5am (show-boundfn operator-arglist (defweak symbol-function fboundp operator-arglist swank operator-arglist slynk operator-arglist)) (defmacro defequivs (namespace boundp sl-name &rest packages) "Define a name which is already the same in multiple packages." `(defweak ,namespace ,boundp ,sl-name ,@packages)) #+5am (show-boundfn operator-arglist (defequivs symbol-function fboundp operator-arglist swank slynk)) (defmacro defsl (sl-name fn eq-ql &rest preflist) (with-gensyms (fs qq) `(let ((,fs (if (functionp ',fn) ',fn (symbol-function ',fn))) (,qq ,eq-ql)) (cond ((eql `(,,fs ,,qq) '(:fn :eq)) (defequivs symbol-function fboundp ,sl-name ,@preflist)) ((eql `(,,fs ,,qq) '(:sym :eq)) (defequivs symbol-value boundp ,sl-name ,@preflist)) ((eql ,fs `(:fn ,,qq)) (defweak symbol-function fboundp ,sl-name ,qq)) ((eql ,fs `(:sym ,,qq)) (defweak symbol-value boundp ,sl-name ,qq)) (t (if (eql ,qq :eq) (defequivs ,fn ,sl-name ,@preflist) (defweak ,fs ,sl-name ,qq))))))) #+5am (defsl operator-arglist fboundp :eq slynk swank) #+5am (defsl operator-arglist :fn :eq slynk swank)
3,152
Common Lisp
.lisp
61
42.459016
102
0.624187
equwal/defsl
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
9489eadefd72b7473fe6f3040701869f5fe9431fdeb0a272de0d0304952bb477
44,247
[ -1 ]
44,248
utils.lisp
equwal_defsl/utils.lisp
(in-package :sl) (eval-when (:compile-toplevel :load-toplevel :execute) ;; From Graham's OnLisp (defun pack (obj) "Ensure obj is a cons." (if (consp obj) obj (list obj))) (defun shuffle (x y) "Interpolate lists x and y with the first item being from x." (cond ((null x) y) ((null y) x) (t (list* (car x) (car y) (shuffle (cdr x) (cdr y)))))) (defun interpol (obj lst) "Intersperse an object in a list." (shuffle lst (loop for #1=#.(gensym) in (cdr lst) collect obj))) (defun group (source n) (labels ((rec (source acc) (let ((rest (nthcdr n source))) (if (consp rest) (rec rest (cons (subseq source 0 n) acc)) (nreverse (cons source acc)))))) (if source (rec source nil) nil))) (defun select (fn lst) "Return the first element that matches the function." (if (null lst) nil (let ((val (funcall fn (car lst)))) (if val (values (car lst) val) (select fn (cdr lst)))))) (defun gen-case (base ex) (if (symbolp ex) (list 'eql base ex) (append ex (list base)))) (defun select-preference (boundp qnames) "Choose the function to use based on user preference." (labels ((select-preference-aux (boundp qnames preflist) (when preflist (let* ((res (select (lambda (x) (string-equal (car x) (car preflist))) qnames)) (package (car res)) (symname (cadr res))) (if (and res (find-package package)) (values symname package) (select-preference-aux boundp qnames (cdr preflist))))))) (select-preference-aux boundp qnames (mapcar #'car qnames)))) (defmacro with-gensyms (symbols &body body) "Create gensyms for those symbols." `(let (,@(mapcar #'(lambda (sym) `(,sym ',(gensym))) symbols)) ,@body)))
2,212
Common Lisp
.lisp
56
27.232143
80
0.500697
equwal/defsl
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
da48e4c652b2468007f53642deb3fd8bd060d2b40231cf0f695dd91b89489d0d
44,248
[ -1 ]
44,249
sl.lisp
equwal_defsl/sl.lisp
;;; Provide least common denominator shared functionality between Sly and Slime. (in-package :sl) ;(defequivsfn operator-arglist)
132
Common Lisp
.lisp
3
42.333333
80
0.811024
equwal/defsl
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
466f6c788225927c6a32eaf7ea5ebea380849f9f274201ab27a5315555b52aed
44,249
[ -1 ]
44,250
sl.asd
equwal_defsl/sl.asd
(defpackage :sl-system (:use :cl :asdf)) (in-package :sl-system) (defsystem :sl :version "1.0" :description "Wrapper for the lowest common denominator of Sly and Slime" :author "Spenser Truex <[email protected]>" :serial t :license "GNU GPL v3" :components ((:file "package") (:file "utils") (:file "macrolayer") (:file "sl")) :weakly-depends-on (:slynk :swank) :depends-on (:alexandria))
473
Common Lisp
.asd
14
28.357143
76
0.593886
equwal/defsl
0
0
0
GPL-3.0
9/19/2024, 11:51:48 AM (Europe/Amsterdam)
8e0f02ad4f8d24b91f7923e85d2728a775517957fc163bb5a6e2fc8c426d044c
44,250
[ -1 ]
44,270
minerva.lisp
maximinus_Minerva/minerva.lisp
;;;; minerva.lisp (asdf:load-asd #P"/home/sparky/data/code/Minerva/minerva.asd") (ql:quickload "minerva") (ql:quickload "minerva/tests") ;; now you can run a test with this syntax ;; (fiveam:run! 'minerva/tests::base-tests)
226
Common Lisp
.lisp
6
36.333333
62
0.733945
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
cf3be5f4ff5106a9c566913a6c6d428e39d81f5c7d4bd2cc7e6096af84dc892a
44,270
[ -1 ]
44,271
package.lisp
maximinus_Minerva/test/package.lisp
;; define test packages here (defpackage :minerva/tests (:use :cl :fiveam))
79
Common Lisp
.lisp
3
24.333333
28
0.733333
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
e47a6e6d2cf129076552415d6b735d6ab7d04fd4ffe2b47bd233044a43b557eb
44,271
[ -1 ]
44,272
test-widgets.lisp
maximinus_Minerva/test/test-widgets.lisp
(in-package :minerva/tests) (def-suite test-widgets :description "Test the ColorRect") (def-suite* test-colorrect :in test-widgets) (test size-matches (let ((foo (make-instance 'minerva:ColorRect :size (minerva::make-size 10 20)))) (is (and (equal (minerva::width (minerva::min-size foo)) 10) (equal (minerva::height (minerva::min-size foo)) 20))))) (test test-no-background-default (let ((foo (make-instance 'minerva:ColorRect :size (minerva::make-size 10 10) :color '(0 0 0 0)))) (is (equal (minerva::background foo) nil))))
552
Common Lisp
.lisp
11
46.909091
100
0.697761
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
f9b1eb66b15c756ae4231d515539031dbbe0062e333b17db62abda8a252291aa
44,272
[ -1 ]
44,273
test-base.lisp
maximinus_Minerva/test/test-base.lisp
(in-package :minerva/tests) (def-suite base-tests :description "Test base helper classes") (def-suite* test-expand :in base-tests) (test expand-none-not-horizontal (is (not (minerva:horizontal-expandp 'minerva:expand-none)))) (test expand-vertical-not-horizontal (is (not (minerva:horizontal-expandp 'minerva:expand-vertical)))) (test expand-horizontal-horizontal (is (minerva:horizontal-expandp 'minerva:expand-horizontal))) (test expand-both-horizontal (is (minerva:horizontal-expandp 'minerva:expand-both))) (test expand-none-not-vertical (is (not (minerva:vertical-expandp 'minerva:expand-none)))) (test expand-horizontal-not-vertical (is (not (minerva:vertical-expandp 'minerva:expand-horizontal)))) (test expand-vertical-vertical (is (minerva:vertical-expandp 'minerva:expand-vertical))) (test expand-both-vertical (is (minerva:vertical-expandp 'minerva:expand-both))) (def-suite* test-size :in base-tests) (test size-constructor (is (minerva::make-size 10 10))) (test size-init-zero (let ((w (make-instance 'minerva:Size))) (is (and (equal (minerva::width w) 0) (equal (minerva::height w) 0))))) (test size-can-set (let ((w (make-instance 'minerva:Size))) (setf (minerva::width w) 100) (setf (minerva::height w) 150) (is (and (equal (minerva::width w) 100) (equal (minerva::height w) 150))))) (test size-initset (let ((w (make-instance 'minerva:Size :width 100 :height 150))) (is (and (equal (minerva::width w) 100) (equal (minerva::height w) 150))))) (test size-equal (let ((foo (make-instance 'minerva:Size :width 50)) (bar (make-instance 'minerva:Size :width 50))) (is (minerva:equal-size foo bar)))) (def-suite* test-position :in base-tests) (test position-constructor (is (minerva::make-position 5 7))) (test create-position (let ((w (make-instance 'minerva:Position))) (is (and (equal (minerva::x w) 0) (equal (minerva::y w) 0))))) (test update-position (let ((w (make-instance 'minerva:Position))) (setf (minerva::x w) 50) (is (equal (minerva::x w) 50)))) (test add-position (let* ((a (make-instance 'minerva:Position :x 10 :y 20)) (b (make-instance 'minerva:Position :x 12 :y 15)) (result (minerva::add a b))) (is (and (equal (minerva::x result) 22) (equal (minerva::y result) 35))))) (test sub-position (let* ((a (make-instance 'minerva:Position :x 20 :y 30)) (b (make-instance 'minerva:Position :x 10 :y 18)) (result (minerva::sub a b))) (is (and (equal (minerva::x result) 10) (equal (minerva::y result) 12))))) (def-suite* test-widget :in base-tests) (test widget-defaults (let ((w (make-instance 'minerva:Widget))) (is (and (equal (minerva::background w) nil) (equal (minerva::expand w) 'minerva:expand-none) (equal (minerva::parent w) nil) (equal (minerva::texture w) nil) (equal (minerva::container w) nil))))) (test default-no-parent (let ((w (make-instance 'minerva:Widget))) (is (equal (minerva::get-parent w) nil)))) (test default-align-size (let* ((w (make-instance 'minerva:Widget)) (offset (minerva::get-align-offset w (make-instance 'minerva:Size :width 100 :height 100) (make-instance 'minerva:Size :width 200 :height 200)))) (is (and (equal (minerva::x offset) 0) (equal (minerva::y offset) 0)))))
3,385
Common Lisp
.lisp
82
37.170732
71
0.676749
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
bfd074631eb01bd01888dec06b75d17b201af58991d0ae585313df06e291f430
44,273
[ -1 ]
44,274
test-containers.lisp
maximinus_Minerva/test/test-containers.lisp
(in-package :minerva/tests) (def-suite test-containers :description "Test all container widgets") (def-suite* test-box :in test-containers) (test widget-creation (is (make-instance 'minerva:Box))) (test empty-box-no-size (let* ((foo (make-instance 'minerva:Box)) (widget-size (minerva::min-size foo))) (is (and (equal (minerva::width widget-size) 0) (equal (minerva::height widget-size) 0))))) (test not-empty-size (let* ((crect (make-instance 'minerva:ColorRect :size (minerva::make-size 50 80))) (foo (make-instance 'minerva:Box :widgets (list crect))) (widget-size (minerva::min-size foo))) (is (and (equal (minerva::width widget-size) 50) (equal (minerva::height widget-size) 80))))) (def-suite* test-hbox-vbox :in test-containers) (test empty-hbox-no-size (let* ((foo (make-instance 'minerva:HBox)) (widget-size (minerva::min-size foo))) (is (and (equal (minerva::width widget-size) 0) (equal (minerva::height widget-size) 0))))) (test size-with-color-rect (let* ((crect (make-instance 'minerva:ColorRect :size (minerva::make-size 20 30))) (foo (make-instance 'minerva:HBox :widgets (list crect))) (widget-size (minerva::min-size foo))) (is (and (equal (minerva::width widget-size) 20) (equal (minerva::height widget-size) 30))))) (test size-with-two-colorrects (let* ((crect1 (make-instance 'minerva:ColorRect :size (minerva::make-size 20 30))) (crect2 (make-instance 'minerva:ColorRect :size (minerva::make-size 30 40))) (foo (make-instance 'minerva:HBox :widgets (list crect1 crect2))) (widget-size (minerva::min-size foo))) (is (and (equal (minerva::width widget-size) 50) (equal (minerva::height widget-size) 40)))))
1,723
Common Lisp
.lisp
36
44.194444
85
0.691711
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
70a3c7aa575e125cd7289fe3605d7f36d03dced415b3edee23129cc6d16cbb6f
44,274
[ -1 ]
44,275
base_example.lisp
maximinus_Minerva/examples/base_example.lisp
(asdf:load-asd #P"/home/sparky/data/code/Minerva/minerva.asd") (ql:quickload "sdl2") (ql:quickload "sdl2-image") (ql:quickload "sdl2-ttf") (ql:quickload "minerva") (in-package :minerva) (defun single-colorrect-example () (let* ((crect (make-instance 'ColorRect :size (make-size 256 256) :color '(255 0 0 0))) (example-frame (make-frame (make-size 256 256) (make-pos 64 64) (list crect)))) (start-minerva (list example-frame)))) (single-colorrect-example)
466
Common Lisp
.lisp
11
40.363636
89
0.716814
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
d5cdc98e9a1d5dd4b4b1c1e1216426d05cac9f60fe864854855add452035df47
44,275
[ -1 ]
44,276
package.lisp
maximinus_Minerva/src/package.lisp
;; define the packages here (defpackage :minerva (:use :cl) (:shadow :Position) (:export :Font :load-font :get-texture :horizontal-expandp :vertical-expandp :expand-horizontal :expand-vertical :expand-none :expand-both :align-left :align-right :align-top :align-bottom :align-center :Size :equal-size :Position :Widget :ColorRect :Box :HBox :wait-for-keypress :init-window))
415
Common Lisp
.lisp
16
22.4375
66
0.713568
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
1c0feab7066b3a532e399775f6fd2d390f347a169e7248c385f890d7eab81f41
44,276
[ -1 ]
44,277
main.lisp
maximinus_Minerva/src/main.lisp
(in-package :minerva) (defun init-window () (sdl2:init) (sdl2-ttf:init) (sdl2:create-window :title "Minerva IDE" :w 640 :h 480 :flags '(:shown))) (defun draw-color (display) (sdl2:fill-rect display nil (sdl2:map-rgb (sdl2:surface-format display) 255 0 0))) (defun wait-for-keypress () (sdl2:with-event-loop (:method :poll) (:quit () t) (:keydown () t) (:idle () (sdl2:delay 100)))) (defun load-image (filepath) (let ((image (sdl2-image:load-image filepath))) (error "Cannot load image ~a (check that file exists)" filepath) image)) (defun test-window () (let* ((window (init-window)) (display (sdl2:get-window-surface window)) (image (load-image #P"data/code/Minerva/assets/images/dog.png")) (my-font (load-font #P"data/code/Minerva/assets/fonts/inconsolata.ttf" 24))) (draw-color display) (sdl2:blit-surface image nil display nil) (sdl2:blit-surface (get-texture my-font "Hello, World!") nil display nil) (sdl2:update-window window) (wait-for-keypress) (sdl2:quit))) (defclass MinervaApp () ;; the base Minerva class, the start of it all ((display :initarg :display :accessor display) (frames :initarg :frames :accessor frames)) (:default-initargs :display nil :frames nil)) (defun start-minerva (new-frames) (sdl2:init) (sdl2-ttf:init) (let ((app (make-instance 'MinervaApp :frames new-frames)) (window (sdl2:create-window :title "Minerva IDE" :w 640 :h 480 :flags '(:shown)))) (setf (display app) (sdl2:get-window-surface window)) (render-all app) (sdl2:update-window (display app)) (event-loop app))) (defmethod render-all ((self MinervaApp)) (loop for frame in (frames self) do (render-frame frame) (sdl2:blit-surface (texture frame) nil (display self) (get-render-rect frame)))) (defmethod event-loop ((self MinervaApp)) (sdl2:with-event-loop (:method :poll) (:quit () t) (:keydown () t) (:idle () (sdl2:delay 100))))
2,004
Common Lisp
.lisp
57
31
84
0.66856
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
3f3454610404784b57f31a2a65a3ce7e3f57240b96e56012effcf22f9801791d
44,277
[ -1 ]
44,278
widgets.lisp
maximinus_Minerva/src/widgets.lisp
;; Simple widgets for the GUI ;; ColorRect is mainly used as a test widget (in-package :minerva) (defclass ColorRect (Widget) ((size :initarg :size :accessor size) (color :initarg :color :accessor color))) (defmethod min-size ((self ColorRect)) (size self)) (defmethod draw ((self ColorRect) new-size) (setf (current-size self) new-size) (get-texture self new-size) (if (not (equal (background self) nil)) (sdl2:fill-rect (texture self) nil (sdl2:map-rgb (sdl2:surface-format (texture self) (background self))))) (let ((draw-pos (get-align-offset self (size self) new-size))) (sdl2:render-draw-rect (texture self) (sdl2:make-rect (x draw-pos) (y draw-pos) (width size) (height size)))))
716
Common Lisp
.lisp
15
44.8
114
0.707317
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
9e40c013297a806153a61e2ed81531ba24aa8f3ea23f7cb58431e6ccab8ac6c2
44,278
[ -1 ]
44,279
base.lisp
maximinus_Minerva/src/base.lisp
(in-package :minerva) (defconstant screen-width 640) (defconstant screen-height 480) (defclass Font () ((sdl-font :initarg :sdl-font :reader sdl-font) (color :initarg :color :accessor color)) (:default-initargs :color '(0 0 0 0))) (defun load-font (font-name size) ;; given a path to a font, load it and return the font object ;; check the path exists (if (probe-file font-name) (progn (let ((loaded-font (sdl2-ttf:open-font font-name size))) (make-instance 'Font :sdl-font loaded-font))) nil)) (defmethod get-texture ((self Font) text) (sdl2-ttf:render-text-blended (sdl-font self) text 0 0 0 0)) ;; a widget can be set to expand or not, given the symbols ;; expand-none, expand-both, expand-vertical and expand-horizontal ;; don't forget that they are namespaced to the mv package (defun horizontal-expandp (expand) (member expand '(expand-horizontal expand-both))) (defun vertical-expandp (expand) (member expand '(expand-vertical expand-both))) (defclass Size () ((width :initarg :width :accessor width) (height :initarg :height :accessor height)) (:default-initargs :width 0 :height 0)) (defun make-size (w h) (make-instance 'Size :width w :height h)) (defmethod equal-size ((size1 Size) (size2 Size)) (and (equal (width size1) (width size2)) (equal (height size1) (height size2)))) (defclass Margin () ((left :initarg :left :accessor left) (right :initarg :right :accessor right) (top :initarg :top :accessor top) (bottom :initarg :bottom :accessor bottom)) (:default-initargs :left 0 :right 0 :top 0 :bottom 0)) (defun make-margin (left right top bottom) (make-instance 'Margin :left left :right right :top top :bottom bottom)) (defclass Position () ((x :initarg :x :accessor x) (y :initarg :y :accessor y)) (:default-initargs :x 0 :y 0)) (defun make-pos (x y) (make-instance 'Position :x x :y y)) (defmethod add ((a Position) &rest b) (let ((xpos (x a)) (ypos (y a))) (dolist (pos b) (incf xpos (x pos)) (incf ypos (y pos))) (make-instance 'Position :x xpos :y ypos))) (defmethod sub ((a Position) &rest b) (let ((xpos (x a)) (ypos (y a))) (dolist (pos b) (decf xpos (x pos)) (decf ypos (y pos))) (make-instance 'Position :x xpos :y ypos))) (defclass Align () ((x :initarg :x :accessor x) (y :initarg :y :accessor y)) (:default-initargs :x 'align-left :y 'align-top)) (defclass Widget () ((expand :initarg :expand :accessor expand) (align :initarg :align :accessor align) (parent :initarg :parent :accessor parent) (texture :initarg :texture :accessor texture) (background :initarg :background :accessor background) (current-size :initarg :current-size :accessor current-size) (offset :initarg :offset :accessor offset) (container :initarg :container :accessor container)) (:default-initargs :background nil :expand 'expand-none :align 'align-top-left :parent nil :texture nil :current-size (make-size 0 0) :offset nil :container nil)) ;; Every widget has the following properties ;; align: how to align when the space allocated is bigger than the widget ;; expand: if the widget is allowed to expand or not, and in what direction ;; some widgets may ignore this value ;; parent: the parent widget, or nil if there is no parent ;; texture: an SDL texture which the widget is rendered to ;; background: a background color which is blitted onto the texture before widget rendering ;; current-size: the size of the last render of the widget ;; offset: the offset of this widget compared to its parent ;; container: t if the widget holds other widgets ;; Every widget has the following methods: ;; min-size: returns a Size stating the smalledt possible space in which a widget can be rendered ;; render: draws the widget on to it's own texture, which is set to the size given ;; this is also passed an offset value which is the widgets offset to the parent ;; draw: draws the widget onto it's texture ;; get-texture: makes a new texure of the required size and format ;; get-parent: returns the parent widget or nil ;; get-align-offset: ;; returns the offset position when the texture is larger than the widget (defmethod min-size ((self Widget)) ;; on a raw widget, this is always (0, 0) (make-instance 'Size :width 0 :height 0)) (defmethod render ((self Widget) size offset) (if (not (equal-size size (current-size self))) (progn (setf (offset self) offset) (setf (current-size self) size) (draw self size)))) (defmethod draw ((self Widget) size) (get-texture self size) (if (not (eq (background self) nil)) (sdl2:fill-rect (texture self) nil (background self))) (setf (current-size self) size)) (defmethod get-texture ((self Widget) size) ;depth is 24 but we should match the display surface really (setf (texture self) (sdl2:create-rgb-surface (width size) (height size) 24))) (defmethod get-parent ((self Widget)) (if (not (eq (parent self) nil)) (get-parent (parent self)))) (defmethod get-align-offset ((self Widget) widget-size given-size) (let ((offset (make-instance 'Position :x 0 :y 0)) (horizontal-space (- (width given-size) (width widget-size))) (vertical-space (- (height given-size) (height widget-size)))) (if (> horizontal-space 0) (cond ((eq (align self) 'align-center) (setf (x offset) (+ (x offset) (/ horizontal-space 2)))) ((eq (align self) 'align-right) (setf (x offset) (+ (x offset) horizontal-space))))) (if (> vertical-space 0) (cond ((eq (align self) 'align-center) (setf (y offset) (+ (y offset) (/ vertical-space 2)))) ((eq (align self) 'align-bottom) (setf (y offset) (+ (y offset) vertical-space))))) offset))
5,890
Common Lisp
.lisp
142
38.056338
101
0.683409
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
8d5c3af0aad88cec3f3613b46919eb8d192534155927cbe9be3ae4e63fc9005e
44,279
[ -1 ]
44,280
containers.lisp
maximinus_Minerva/src/containers.lisp
(in-package :minerva) ;; in addition to the base widgets, containers have the following additional properties ;; widgets: the widgets held by the container ;; and the following methods ;; add-widget: adds the widget to the container and sets its parent (defclass Box (Widget) ;; box will display the first widget in it's widgets only ((widgets :initarg :widgets :accessor widgets)) (:default-initargs :widgets nil :container t)) (defmethod min-size ((self Box)) (if (equal (widgets self) nil) (make-instance 'Size :width 0 :height 0) (min-size (first (widgets self))))) (defmethod add-widget ((self Box) new-widget) (setf (parent new-widget) self) (setf (widgets self) (append (widgets self) (list new-widget)))) (defmethod draw ((self Box) size) ;; children are drawn on top of each other (get-texture self size) (if (not (equal (background self) nil)) (sdl2:fill-rect (texture self) nil (background self))) (loop for widget in (widgets self) do (render widget size (make-position 0 0)) (sdl2:blit-surface (texture widget) nil (texture self) nil))) (defmethod expand-policy ((self Box)) ;; expanding depends on wether the children do or not (let ((x-expand nil) (y-expand nil)) (loop for widget in (widgets self) do (if (not (eq (expand self) 'expand-none)) (progn (if (eq (expand self) 'expand-both) (return-from expand-policy 'expand-both)) (if (eq (expand self) 'expand-horizontal) (setf x-expand t)) (if (eq (expand self) 'expand-vertical) (setf y-expand t)))) (if (and x-expand y-expand) (return-from expand-policy 'expand-both))) (if x-expand (return-from expand-policy 'expand-horizontal)) (if y-expand (return-from expand-policy 'expand-vertical)) 'expand-none)) (defclass Margin (Box) ((margins :initarg :margins :accessor margins)) (:default-initargs margins (make-margin 0 0 0 0))) (defun make-margin (margins &rest initargs) (let ((new-margin (apply 'make-instance 'Margin initargs))) (setf (margine new-margin) margins))) (defmethod min-size ((self Margin)) (let ((render-size (make-size 0 0))) (loop for widget in (widgets self) do (let ((widget-size (min-size widget))) (setf (width render-size) (max (width render-size) (width widget-size))) (setf (height render-size) (max (height render-size) (height widget-size))))) (incf (width render-size) (+ (left self) (right self))) (incf (height render-size) (+ (top self) (bottom self))) render-size)) (defmethod draw ((self Margin) size) (get-texture self size) (if (not (equal (background self) nil)) (sdl2:fill-rect (texture self) nil (background self))) (decf (width size) (+ (left self) (right self))) (decf (height size) (+ (top self) (bottom self))) (let ((offset-position (make-position (left self) (top self)))) (loop for widget in (widgets self) do (render widget size offset-position) (sdl2:blit-surface (texture widget) nil (texture self) nil)))) (defclass HBox (Box) ()) (defmethod min-size ((self HBox)) (let ((base-size (make-size 0 0))) (loop for widget in (widgets self) do (let ((widget-size (min-size widget))) (incf (width base-size) (width widget-size)) (setf (height base-size) (max (height base-size) (height widget-size))))) base-size)) (defmethod calculate-size ((self HBox) available-size) (let ((fixed-width 0) (expandable-count 0) (remaining-width 0) (expand-width 0) (extra-width 0) (final-widths nil) (height 0)) (loop for widget in (widgets self) do (if (horizontal-expandp (expand widget)) (incf expandable-count 1)) (incf fixed-width (width (min-size widget)))) (setf remaining-width (- (width available-size) fixed-width)) (setf remaining-width (max 0 remaining-width)) (if (> expandable-count 0) (progn (setf expand-width (floor remaining-width expandable-count)) (setf extra-width (mod remaining-width expandable-count)))) ;; note that the height for each widget should be the same as the highest widget, else the widget cannot center (if (not (equal (widgets self) nil)) (setf height (apply #'max (mapcar (lambda (x) (height (min-size x))) (widgets self))))) (loop for widget in (widgets self) do (if (vertical-expandp (expand widget)) (setf height (height available-size))) (if (vertical-expandp (expand widget)) (progn ;; distribute the remaining width to ensure total width matches (if (> extra-width 0) (progn (nconc final-widths (list (make-instance 'Size :width (+ (width (min-size widget)) expand-width 1) :height height))) (decf extra-width)) (nconc final-widths (list (make-instance 'Size :width (+ (width (min-size widget)) expand-width :height height)))))) (nconc final-widths (list (make-instance 'Size :width (width (min-size)) :height height))))) final-widths)) (defmethod draw ((self HBox) new-size) (get-texture new-size) (if (not (equal (background self) nil)) (sdl2:fill-rect (texture self) nil (sdl2:map-rgb (sdl2:surface-format (texture self) (background self))))) (if (not equal (widgets self) nil) (let* ((all-sizes (calculate-size self)) (max-height (apply #'max (mapcar (lambda (x) (height (min-size x)) all-sizes)))) (total-area (make-instance 'Size :width (loop for i in (widgets self) sum (width i)) :height height)) (xpos 0) (ypos 0) (widget-offset (frame-offset self)) (offset (get-align-offset self total-area new-size))) (incf xpos (x widget-offset)) (incf ypos (y widget-offset)) (loop for widget in (widgets self) for widget-size in all-sizes do (setf (height widget-size) max-height) (render widget (make-instance 'Position :x (x offset) :y (y offset))) ;; blit the texture onto our texture (sdl2:blit-surface (texture widget) nil (texture self) (sdl2:make-rect xpos ypos (width widget-size) (height widget-size))) (incf xpos (width widget-size)) (incf (x offset) (width widget-size)))))) (defclass Frame (Widget) ((frame-position :initarg :frame-position :accessor frame-position) (modal :initarg :modal :accessor modal) (widgets :initarg :widgets :accessor widgets)) (:default-initargs :widgets nil :modal nil :container t)) ;; frames are like a single box, however they never expand and have a fixed size ;; so current-size is always fixed ;; they may have >1 widget, extra widgets are drawn on top of the others (defun make-frame (size pos widgets &rest initargs) ;; widgets must be a list (let ((new-frame (apply 'make-instance 'Frame initargs))) (setf (current-size new-frame) size) (setf (frame-position new-frame) pos) (setf (widgets new-frame) widgets) (get-texture new-frame size) new-frame)) (defmethod render-frame ((self Frame)) ;; render relies on a size being given, so we use a different function here (loop for widget in (widgets self) do (render widget (current-size self) (make-pos 0 0)) ;; render the texture onto our texture (sdl2:blit-surface (texture widget) nil (texture self) nil))) (defmethod get-render-rect ((self Frame)) (sdl2:make-rect (x (frame-position self)) (y (frame-position self)) (width (current-size self)) (height (current-size self))))
7,302
Common Lisp
.lisp
160
41.59375
125
0.689389
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
163177a4400ef20aa2de445545b2c40378721babf6b238242bc60331c22de185
44,280
[ -1 ]
44,281
minerva.asd
maximinus_Minerva/minerva.asd
;;;; minerva.asd - define all systems here (asdf:defsystem "minerva" :description "Minerva: The modern Lisp IDE" :author "Chris Handy <[email protected]>" :license "GPL 3.0" :version "0.0.1" :serial t :depends-on (:sdl2 :sdl2-ttf :sdl2-image) :pathname "src/" :components ((:file "package") (:file "base") (:file "widgets") (:file "containers") (:file "main"))) (asdf:defsystem :minerva/tests :description "Tests for Minerva IDE" :author "Chris Handy <[email protected]>" :license "GPL 3.0" :serial t :depends-on (:fiveam :minerva) :pathname "test/" :components ((:file "package") (:file "test-base") (:file "test-widgets") (:file "test-containers")))
745
Common Lisp
.asd
25
25.24
45
0.633194
maximinus/Minerva
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
d842b80d481ac65f3bc77e504cb3fecfb8c95cbc30926a815b4e727134dc148e
44,281
[ -1 ]
44,309
syncfile.lsp
KupipiKuki_BricsCAD_Lisp/syncfile.lsp
(defun jc:syncfile (fromDir toDir / fileList toFileList isDir fileItem cpType) (setq isDir (vl-directory-files toDir)) (setq fileList ( vl-directory-files fromDir nil 1 )) (if fileList (progn (if (not isDir ) (progn (vl-mkdir toDir) (princ "Destination Directory Not Found, Creating It.\n") ) (setq toFileList (vl-directory-files toDir nil 1)) ) (foreach fileItem fileList (setq cpType (jc:timecompare (vl-file-systime (strcat fromDir fileItem)) (vl-file-systime (strcat toDir fileItem)))) (if (> cpType 0) (progn (if (= cpType 1) (progn (princ fileItem) (princ " is Modified, Copying..\n") (vl-file-delete (strcat toDir fileItem)) (vl-file-copy (strcat fromDir fileItem) (strcat toDir fileItem)) ) (progn (princ fileItem) (princ " is New, Copying..\n") (vl-file-copy (strcat fromDir fileItem) (strcat toDir fileItem)) ) ) ) (progn (if (= cpType -3) (progn (princ fileItem) (princ " local file is synced or has been modified, Skipping..\n") ) (progn (princ fileItem) (princ " is not modified, Skipping..\n") ) ) ) ) ) (princ "Process Completed\n") ) (princ "Error In Source Directory, Exiting...\n") ) (princ) ) (defun jc:timeCompare ( a b / inLoop retVal) (if (= b nil) (setq retVal 2) (progn (if (= a nil) (setq retVal -2) (progn (if (not (= a b) ) (progn (setq inLoop 0) (while (> inLoop -1) (if (and (/= inLoop 2) (> (nth inLoop a)(nth inLoop b)) ) (progn (setq inLoop -1) (setq retVal 1) ) (progn (if (and (/= inLoop 2) (> (nth inLoop b)(nth inLoop a)) ) (progn (setq inLoop -1) (setq retVal -3) ) (setq inLoop (+ inLoop 1)) ) ) ) (if (= inLoop 8) (progn (setq inLoop -1) (setq retVal -1) ) ) ) ) (setq retVal 0) ) ) ) ) ) retVal )
3,075
Common Lisp
.l
109
14.018349
125
0.368794
KupipiKuki/BricsCAD_Lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
ad04763adc6cc297b831bec7d0efa80cd675d52de685e800bde9f618bb016dba
44,309
[ -1 ]
44,310
FindRep.lsp
KupipiKuki_BricsCAD_Lisp/FindRep.lsp
;By Jason Cheers ; ;Thanks for example source code: ;Lee Mac ;DannyNL @ AutoDesk Forums ;T.Willey @ AUGI Forums ;Help from many forum members accross multiple sites ; ; ************************************************************************ (defun c:FINDREP (oldStr newStr) (setq ss(ssget )) (JMC:FINDREPLACE ss oldStr newStr) (princ) ) (defun c:FINDREPA (oldStr newStr) (setq ss (ssget "x")) (JMC:FINDREPLACE ss oldStr newStr) (princ) ) (defun c:FINDREPEA () (setq oldStrings '("LEFT1","LEFT2","LEFT3","LEFT4","LEFT5","LEFT6","LEFT7","LEFT8","LEFT9","LEFT10","LEFT11","LEFT12", "RIGHT1","RIGHT2","RIGHT3","RIGHT4","RIGHT5","RIGHT6","RIGHT7","RIGHT8","RIGHT9","RIGHT10","RIGHT11","RIGHT12", "POS1","POS2","POS3","POS4","POS5","POS6","POS7","POS8","POS9","POS10","POS11","POS12", "1","2","3","4","5","6","7","8","9","10","11","12")) (setq newStrings '("LEFT13","LEFT14","LEFT15","LEFT16","LEFT17","LEFT18","LEFT19","LEFT20","LEFT21","LEFT22","LEFT23","LEFT24", "RIGHT13","RIGHT14","RIGHT15","RIGHT16","RIGHT17","RIGHT18","RIGHT19","RIGHT20","RIGHT21","RIGHT22","RIGHT23","RIGHT24", "POS13","POS14","POS15","POS16","POS17","POS18","POS19","POS20","POS21","POS22","POS23","POS24", "13","14","15","16","17","18","19","20","21","22","23","24")) (setq ss (ssget "x")) (foreach fndVal oldStrings (setq repPos (vl-position fndVal oldStrings)) (JMC:FINDREPLACE ss fndVal (nth repPos newStrings)) ) (princ) ) (defun c:FINDREPEB () (setq oldStrings '("LEFT1","LEFT2","LEFT3","LEFT4","LEFT5","LEFT6","LEFT7","LEFT8","LEFT9","LEFT10","LEFT11","LEFT12", "RIGHT1","RIGHT2","RIGHT3","RIGHT4","RIGHT5","RIGHT6","RIGHT7","RIGHT8","RIGHT9","RIGHT10","RIGHT11","RIGHT12", "POS1","POS2","POS3","POS4","POS5","POS6","POS7","POS8","POS9","POS10","POS11","POS12", "1","2","3","4","5","6","7","8","9","10","11","12")) (setq newStrings '("LEFT25","LEFT26","LEFT27","LEFT28","LEFT29","LEFT30","LEFT31","LEFT32","LEFT33","LEFT34","LEFT35","LEFT36", "RIGHT25","RIGHT26","RIGHT27","RIGHT28","RIGHT29","RIGHT30","RIGHT31","RIGHT32","RIGHT33","RIGHT34","RIGHT35","RIGHT36", "POS25","POS26","POS27","POS28","POS29","POS30","POS31","POS32","POS33","POS34","POS35","POS36", "25","26","27","28","29","30","31","32","33","34","35","36")) (setq ss (ssget "x")) (foreach fndVal oldStrings (setq repPos (vl-position fndVal oldStrings)) (JMC:FINDREPLACE ss fndVal (nth repPos newStrings)) ) (princ) ) (defun c:FINDREPEC () (setq oldStrings '("LEFT1","LEFT2","LEFT3","LEFT4","LEFT5","LEFT6","LEFT7","LEFT8","LEFT9","LEFT10","LEFT11","LEFT12", "RIGHT1","RIGHT2","RIGHT3","RIGHT4","RIGHT5","RIGHT6","RIGHT7","RIGHT8","RIGHT9","RIGHT10","RIGHT11","RIGHT12", "POS1","POS2","POS3","POS4","POS5","POS6","POS7","POS8","POS9","POS10","POS11","POS12", "1","2","3","4","5","6","7","8","9","10","11","12")) (setq newStrings '("LEFT37","LEFT38","LEFT39","LEFT40","LEFT41","LEFT42","LEFT43","LEFT44","LEFT45","LEFT46","LEFT47","LEFT48", "RIGHT37","RIGHT38","RIGHT39","RIGHT40","RIGHT41","RIGHT42","RIGHT43","RIGHT44","RIGHT45","RIGHT46","RIGHT47","RIGHT48", "POS37","POS38","POS39","POS40","POS41","POS42","POS43","POS44","POS45","POS46","POS47","POS48", "37","38","39","40","41","42","43","44","45","46","47","48")) (setq ss (ssget "x")) (foreach fndVal oldStrings (setq repPos (vl-position fndVal oldStrings)) (JMC:FINDREPLACE ss fndVal (nth repPos newStrings)) ) (princ) ) (defun c:FINDREPED () (setq oldStrings '("B01-","B02-","B03-","B04-","B05-","B06-","B07-","B08-","B09-","B10-","B11-","B12-","B13-","B14-","B15-","B16-")) (setq newStrings '("IN01-","IN02-","IN03-","IN04-","IN05-","IN06-","IN07-","IN08-","IN09-","IN10-","IN11-","IN12-","IN13-","IN14-","IN15-","IN16-")) (setq ss (ssget "x")) (foreach fndVal oldStrings (setq repPos (vl-position fndVal oldStrings)) (JMC:FINDREPLACE ss fndVal (nth repPos newStrings)) ) (princ) ) (defun c:FINDREPEE () (setq oldStrings '("IN01-","IN02-","IN03-","IN04-","IN05-","IN06-","IN07-","IN08-","IN09-","IN10-","IN11-","IN12-","IN13-","IN14-","IN15-","IN16-", "IN01","IN02","IN03","IN04","IN05","IN06","IN07","IN08","IN09","IN10","IN11","IN12","IN13","IN14","IN15","IN16")) (setq newStrings '("01-","02-","03-","04-","05-","06-","07-","08-","09-","10-","11-","12-","13-","14-","15-","16-", "01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16")) (setq ss (ssget "x")) (foreach fndVal oldStrings (setq repPos (vl-position fndVal oldStrings)) (JMC:FINDREPLACE ss fndVal (nth repPos newStrings)) ) (princ) ) (defun c:FINDREPEF () (setq oldStrings '("01-","02-","03-","04-","05-","06-","07-","08-","09-","10-","11-","12-","13-","14-","15-","16-","17-","18-","19-","20-","21-","22-","23-","24-", "01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24")) (setq newStrings '("25-","26-","27-","28-","29-","30-","31-","32-","33-","34-","35-","36-","37-","38-","39-","40-","41-","42-","43-","44-","45-","46-","47-","48-", "25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48")) (setq ss (ssget )) (foreach fndVal oldStrings (setq repPos (vl-position fndVal oldStrings)) (JMC:FINDREPLACE ss fndVal (nth repPos newStrings)) ) (princ) ) (defun JMC:FINDREPLACE ( SB_Selection oldStr newStr / FA_BlkObject FA_Attributes FA_Return) (setq SB_FoundSel (ssadd)) (setq SB_Count 0) (setq SB_Max (sslength SB_Selection)) (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (if (and (or (= (vla-get-ObjectName FA_BlkObject) "AcDbMText") (= (vla-get-ObjectName FA_BlkObject)"AcDbText") (= (vla-get-ObjectName FA_BlkObject) "AcDbMLeader") (= (vla-get-ObjectName FA_BlkObject) "AcDbAttributeDefinition") ) (not (and (= (type FA_BlkObject) 'VLA-OBJECT) (= (vla-get-ObjectName FA_BlkObject) "AcDbBlockReference") ) ) ) (progn (if (= (vla-get-ObjectName FA_BlkObject) "AcDbAttributeDefinition") (progn (if (equal (vla-get-PromptString FA_BlkObject) oldStr) (vla-put-PromptString FA_BlkObject newStr) ) (if (equal (vla-get-TagString FA_BlkObject) oldStr) (vla-put-TagString FA_BlkObject newStr) ) ) (if (equal (vla-get-TextString FA_BlkObject) oldStr) (vla-put-TextString FA_BlkObject newStr) ) ) ) ) (setq SB_Count (1+ SB_Count)) ) )
7,080
Common Lisp
.l
146
41.828767
166
0.555459
KupipiKuki/BricsCAD_Lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
9b8e53ebffba36d45dd6899bba8f5e05ca248a4dc167e92bf98a351b748fd28c
44,310
[ -1 ]
44,311
setObjectColor.lsp
KupipiKuki_BricsCAD_Lisp/setObjectColor.lsp
;By Jason Cheers ; ;Thanks for example source code: ;Lee Mac ;DannyNL @ AutoDesk Forums ;Help from many forum members accross multiple sites ; ; ************************************************************************ (defun LM:ApplytoBlockObjects ( blks name func / def result ) (setq func (eval func)) (if (not (vl-catch-all-error-p (setq def (vl-catch-all-apply 'vla-item (list blks name))))) (vlax-for obj def (setq result (cons (func obj) result))) ) (reverse result) ) (defun c:MMBL ( / FA_BlkObject FA_Attributes FA_Return) (setq SB_Selection (ssget )) (setq SB_FoundSel (ssadd)) (setq SB_Count 0) (setq SB_Max (sslength SB_Selection)) (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (if (and (= (type FA_BlkObject) 'VLA-OBJECT) (= (vla-get-ObjectName FA_BlkObject) "AcDbBlockReference") ) (progn (if (= (vla-get-HasAttributes FA_BlkObject) :vlax-true) (progn (setq FA_Attributes (vlax-safearray->list (vlax-variant-value (vla-GetAttributes FA_BlkObject)))) (foreach FA_Item FA_Attributes (if (= (vla-get-invisible FA_Item) :vlax-false) (vla-put-color FA_Item 256) ) ) ) ) (LM:ApplytoBlockObjects (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename FA_BlkObject) '(lambda ( obj ) (vla-put-color obj 256)) ) ) (progn (vla-put-color FA_BlkObject 256) ) ) (setq SB_Count (1+ SB_Count)) (if (> (sslength SB_FoundSel) 0) (sssetfirst nil SB_FoundSel) ) ) ) (defun c:SAMBL ( / FA_BlkObject FA_Attributes FA_Return) (setq SB_Selection (ssget "x")) (setq SB_Selected (ssadd)) (setq SB_FoundSel (ssadd)) (setq SB_Count 0) (setq SB_Max (sslength SB_Selection)) (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (if (= (vla-get-color FA_BlkObject) 256) (ssadd (ssname SB_Selection SB_Count) SB_Selected) ) (setq SB_Count (1+ SB_Count)) (if (> (sslength SB_FoundSel) 0) (sssetfirst nil SB_FoundSel) ) ) (setq SB_Selection nil) (sssetfirst nil SB_Selected) ) (defun c:MMCL ( / FA_BlkObject FA_Attributes FA_Return) (setq mycolor (acad_colordlg 256 T)) (if (not mycolor) (setq mycolor 256) ) (setq SB_Selection (ssget )) (setq SB_FoundSel (ssadd)) (setq SB_Count 0) (setq SB_Max (sslength SB_Selection)) (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (if (and (= (type FA_BlkObject) 'VLA-OBJECT) (= (vla-get-ObjectName FA_BlkObject) "AcDbBlockReference") ) (progn (if (= (vla-get-HasAttributes FA_BlkObject) :vlax-true) (progn (setq FA_Attributes (vlax-safearray->list (vlax-variant-value (vla-GetAttributes FA_BlkObject)))) (foreach FA_Item FA_Attributes (if (= (vla-get-invisible FA_Item) :vlax-false) (vla-put-color FA_Item mycolor) ) ) ) ) (LM:ApplytoBlockObjects (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename FA_BlkObject) '(lambda ( obj ) (vla-put-color obj mycolor)) ) ) (progn (vla-put-color FA_BlkObject mycolor) ) ) (setq SB_Count (1+ SB_Count)) (if (> (sslength SB_FoundSel) 0) (sssetfirst nil SB_FoundSel) ) ) ) (defun c:SAMCL ( / FA_BlkObject FA_Attributes FA_Return) (setq mycolor (acad_colordlg 256 T)) (if (not mycolor) (setq mycolor 256) ) (setq SB_Selection (ssget "x")) (setq SB_Selected (ssadd)) (setq SB_FoundSel (ssadd)) (setq SB_Count 0) (setq SB_Max (sslength SB_Selection)) (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (if (= (vla-get-color FA_BlkObject) mycolor) (ssadd (ssname SB_Selection SB_Count) SB_Selected) ) (setq SB_Count (1+ SB_Count)) (if (> (sslength SB_FoundSel) 0) (sssetfirst nil SB_FoundSel) ) ) (setq SB_Selection nil) (sssetfirst nil SB_Selected) )
4,654
Common Lisp
.l
153
24.261438
103
0.600491
KupipiKuki/BricsCAD_Lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
92115bdd4c66b2875cdccaebc8c4188bc3e4c2c93c896d7d53d8bd4c7bf5f76a
44,311
[ -1 ]
44,312
BlockExplode.lsp
KupipiKuki_BricsCAD_Lisp/BlockExplode.lsp
;By Jason Cheers ; ;Thanks for example source code: ;Lee Mac ;DannyNL @ AutoDesk Forums ;T.Willey @ AUGI Forums ;Help from many forum members accross multiple sites ; ; ************************************************************************ (defun c:ESBLK () (setq ss(ssget )) (JMC:ExplodeAll ss 'pstylemode) (princ) ) (defun c:ESBLKA ( ) (setq ss (ssget "x")) (JMC:ExplodeAll ss 'pstylemode) (princ) ) (defun c:ESBLKAL ( ltab ) (princ ltab) (setq ss (ssget "_x" (list (cons 410 ltab)))) (JMC:ExplodeAllLayout ss 'pstylemode ltab) (princ) ) (defun JMC:ExplodeAll ( SB_Selection psm / FA_BlkObject FA_Attributes FA_Return) (setq SB_FoundSel (ssadd)) (setq SB_Count 0) (setq SB_Max (sslength SB_Selection)) (if (zerop (getvar "pstylemode")) (progn (princ "STB File Detected\n") (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (cond ((= "Remove" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 3)) ((= "Add" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 1)) ((= "Existing" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 0)) ((= "AsBuilt" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 4)) ((= "Revision" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 6)) ) (if (and (= (type FA_BlkObject) 'VLA-OBJECT) (= (vla-get-ObjectName FA_BlkObject) "AcDbBlockReference") ) (progn (if (= (vla-get-HasAttributes FA_BlkObject) :vlax-true) (progn (setq FA_Attributes (vlax-safearray->list (vlax-variant-value (vla-GetAttributes FA_BlkObject)))) (foreach FA_Item FA_Attributes (if (= (vla-get-invisible FA_Item) :vlax-false) (progn (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq TextObj (vla-AddText mspace (vla-get-TextString FA_Item) (vla-get-InsertionPoint FA_Item) (vla-get-Height FA_Item))) (vla-put-Alignment TextObj (vla-get-Alignment FA_Item)) (if (/= (vla-get-Alignment TextObj) 0) (vla-put-TextAlignmentPoint TextObj (vla-get-TextAlignmentPoint FA_Item)) ) (vla-put-Backward TextObj (vla-get-Backward FA_Item)) (vla-put-Layer TextObj (vla-get-Layer FA_Item)) (vla-put-Normal TextObj (vla-get-Normal FA_Item)) (vla-put-ObliqueAngle TextObj (vla-get-ObliqueAngle FA_Item)) (vla-put-Rotation TextObj (vla-get-Rotation FA_Item)) (vla-put-ScaleFactor TextObj (vla-get-ScaleFactor FA_Item)) (vla-put-StyleName TextObj (vla-get-StyleName FA_Item)) (vla-put-UpsideDown TextObj (vla-get-UpsideDown FA_Item)) (vla-put-plotstylename TextObj (vla-get-plotstylename FA_BlkObject)) (vla-put-color TextObj (vla-get-color FA_BlkObject)) ) ) ) ) ) ;(vla-explode FA_BlkObject) ;(princ (vla-get-Name FA_BlkObject)) ;(princ (wcmatch (vla-get-Name FA_BlkObject) "`**")) (setq EX_Selection (vla-explode FA_BlkObject)) (if (not (wcmatch (vla-get-Name FA_BlkObject) "`**")) (progn (setq ss (vlax-safearray->list (vlax-variant-value EX_Selection ) ) ) (foreach ssitem ss (setq ssattn (vla-get-ObjectName ssitem)) (if (= (vla-get-ObjectName ssitem) "AcDbAttributeDefinition") (vla-delete ssitem) (progn (vla-put-plotstylename ssitem (vla-get-plotstylename FA_BlkObject)) (vla-put-color ssitem (vla-get-color FA_BlkObject)) ) ) ) ) ) (vla-delete FA_BlkObject) ) ) (setq SB_Count (1+ SB_Count)) ) ) (progn (princ "CTB File Detected\n") (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (if (and (= (type FA_BlkObject) 'VLA-OBJECT) (= (vla-get-ObjectName FA_BlkObject) "AcDbBlockReference") ) (progn (if (= (vla-get-HasAttributes FA_BlkObject) :vlax-true) (progn (setq FA_Attributes (vlax-safearray->list (vlax-variant-value (vla-GetAttributes FA_BlkObject)))) (foreach FA_Item FA_Attributes (if (= (vla-get-invisible FA_Item) :vlax-false) (progn (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq TextObj (vla-AddText mspace (vla-get-TextString FA_Item) (vla-get-InsertionPoint FA_Item) (vla-get-Height FA_Item))) (vla-put-Alignment TextObj (vla-get-Alignment FA_Item)) (if (/= (vla-get-Alignment TextObj) 0) (vla-put-TextAlignmentPoint TextObj (vla-get-TextAlignmentPoint FA_Item)) ) (vla-put-Backward TextObj (vla-get-Backward FA_Item)) (vla-put-Layer TextObj (vla-get-Layer FA_Item)) (vla-put-Normal TextObj (vla-get-Normal FA_Item)) (vla-put-ObliqueAngle TextObj (vla-get-ObliqueAngle FA_Item)) (vla-put-Rotation TextObj (vla-get-Rotation FA_Item)) (vla-put-ScaleFactor TextObj (vla-get-ScaleFactor FA_Item)) (vla-put-StyleName TextObj (vla-get-StyleName FA_Item)) (vla-put-UpsideDown TextObj (vla-get-UpsideDown FA_Item)) ) ) ) ) ) ;(vla-explode FA_BlkObject) ;(princ (vla-get-Name FA_BlkObject)) ;(princ (wcmatch (vla-get-Name FA_BlkObject) "`**")) (setq EX_Selection (vla-explode FA_BlkObject)) (if (not (wcmatch (vla-get-Name FA_BlkObject) "`**")) (progn (setq ss (vlax-safearray->list (vlax-variant-value EX_Selection ) ) ) (foreach ssitem ss (setq ssattn (vla-get-ObjectName ssitem)) (if (= (vla-get-ObjectName ssitem) "AcDbAttributeDefinition") (vla-delete ssitem) ) ) ) ) (vla-delete FA_BlkObject) ) ) (setq SB_Count (1+ SB_Count)) ) ) ) ) (defun JMC:ExplodeAllLayout ( SB_Selection psm ltab / FA_BlkObject FA_Attributes FA_Return) (setq SB_FoundSel (ssadd)) (setq SB_Count 0) (setq SB_Max (sslength SB_Selection)) (if (zerop (getvar "pstylemode")) (progn (princ "STB File Detected\n") (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (cond ((= "Remove" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 3)) ((= "Add" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 1)) ((= "Existing" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 7)) ((= "AsBuilt" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 4)) ((= "Revision" (vla-get-plotstylename FA_BlkObject))(vla-put-color FA_BlkObject 6)) ) (if (and (= (type FA_BlkObject) 'VLA-OBJECT) (= (vla-get-ObjectName FA_BlkObject) "AcDbBlockReference") ) (progn (if (= (vla-get-HasAttributes FA_BlkObject) :vlax-true) (progn (setq FA_Attributes (vlax-safearray->list (vlax-variant-value (vla-GetAttributes FA_BlkObject)))) (foreach FA_Item FA_Attributes (if (= (vla-get-invisible FA_Item) :vlax-false) (progn (if (= "model" ltab) (progn (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq TextObj (vla-AddText mspace (vla-get-TextString FA_Item) (vla-get-InsertionPoint FA_Item) (vla-get-Height FA_Item))) ) (progn (setq pspace (vla-get-block (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) ltab))) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq TextObj (vlax-invoke-method (vla-get-block (vla-item (vla-get-layouts doc) (getvar 'ctab) ) ) 'addtext (vla-get-TextString FA_Item) (vla-get-InsertionPoint FA_Item) (vla-get-Height FA_Item) ) ) ) ) (vla-put-Alignment TextObj (vla-get-Alignment FA_Item)) (if (/= (vla-get-Alignment TextObj) 0) (vla-put-TextAlignmentPoint TextObj (vla-get-TextAlignmentPoint FA_Item)) ) (vla-put-Backward TextObj (vla-get-Backward FA_Item)) (vla-put-Layer TextObj (vla-get-Layer FA_Item)) (vla-put-Normal TextObj (vla-get-Normal FA_Item)) (vla-put-ObliqueAngle TextObj (vla-get-ObliqueAngle FA_Item)) (vla-put-Rotation TextObj (vla-get-Rotation FA_Item)) (vla-put-ScaleFactor TextObj (vla-get-ScaleFactor FA_Item)) (vla-put-StyleName TextObj (vla-get-StyleName FA_Item)) (vla-put-UpsideDown TextObj (vla-get-UpsideDown FA_Item)) (vla-put-plotstylename TextObj (vla-get-plotstylename FA_BlkObject)) (vla-put-color TextObj (vla-get-color FA_BlkObject)) ) ) ) ) ) ;(vla-explode FA_BlkObject) ;(princ (vla-get-Name FA_BlkObject)) ;(princ (wcmatch (vla-get-Name FA_BlkObject) "`**")) (setq EX_Selection (vla-explode FA_BlkObject)) (if (not (wcmatch (vla-get-Name FA_BlkObject) "`**")) (progn (setq ss (vlax-safearray->list (vlax-variant-value EX_Selection ) ) ) (foreach ssitem ss (setq ssattn (vla-get-ObjectName ssitem)) (if (= (vla-get-ObjectName ssitem) "AcDbAttributeDefinition") (vla-delete ssitem) (progn (vla-put-plotstylename ssitem (vla-get-plotstylename FA_BlkObject)) (vla-put-color ssitem (vla-get-color FA_BlkObject)) ) ) ) ) ) (vla-delete FA_BlkObject) ) ) (setq SB_Count (1+ SB_Count)) ) ) (progn (princ "CTB File Detected\n") (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (if (and (= (type FA_BlkObject) 'VLA-OBJECT) (= (vla-get-ObjectName FA_BlkObject) "AcDbBlockReference") ) (progn (if (= (vla-get-HasAttributes FA_BlkObject) :vlax-true) (progn (setq FA_Attributes (vlax-safearray->list (vlax-variant-value (vla-GetAttributes FA_BlkObject)))) (foreach FA_Item FA_Attributes (if (= (vla-get-invisible FA_Item) :vlax-false) (progn (if (= "model" ltab) (progn (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq TextObj (vla-AddText mspace (vla-get-TextString FA_Item) (vla-get-InsertionPoint FA_Item) (vla-get-Height FA_Item))) ) (progn (setq pspace (vla-get-block (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) ltab))) (setq TextObj (vlax-invoke pspace 'addtext (vla-get-TextString FA_Item) (vla-get-InsertionPoint FA_Item) (vla-get-Height FA_Item))) ) ) (vla-put-Alignment TextObj (vla-get-Alignment FA_Item)) (if (/= (vla-get-Alignment TextObj) 0) (vla-put-TextAlignmentPoint TextObj (vla-get-TextAlignmentPoint FA_Item)) ) (vla-put-Backward TextObj (vla-get-Backward FA_Item)) (vla-put-Layer TextObj (vla-get-Layer FA_Item)) (vla-put-Normal TextObj (vla-get-Normal FA_Item)) (vla-put-ObliqueAngle TextObj (vla-get-ObliqueAngle FA_Item)) (vla-put-Rotation TextObj (vla-get-Rotation FA_Item)) (vla-put-ScaleFactor TextObj (vla-get-ScaleFactor FA_Item)) (vla-put-StyleName TextObj (vla-get-StyleName FA_Item)) (vla-put-UpsideDown TextObj (vla-get-UpsideDown FA_Item)) ) ) ) ) ) ;(vla-explode FA_BlkObject) ;(princ (vla-get-Name FA_BlkObject)) ;(princ (wcmatch (vla-get-Name FA_BlkObject) "`**")) (setq EX_Selection (vla-explode FA_BlkObject)) (if (not (wcmatch (vla-get-Name FA_BlkObject) "`**")) (progn (setq ss (vlax-safearray->list (vlax-variant-value EX_Selection ) ) ) (foreach ssitem ss (setq ssattn (vla-get-ObjectName ssitem)) (if (= (vla-get-ObjectName ssitem) "AcDbAttributeDefinition") (vla-delete ssitem) ) ) ) ) (vla-delete FA_BlkObject) ) ) (setq SB_Count (1+ SB_Count)) ) ) ) )
15,648
Common Lisp
.l
324
31.54321
176
0.496306
KupipiKuki/BricsCAD_Lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
d5c4be912b8a549c464b7df96d56849fe3982c1007b7b9482e621cf203415905
44,312
[ -1 ]
44,313
copyPaste.lsp
KupipiKuki_BricsCAD_Lisp/copyPaste.lsp
(defun c:copyatt ( ) (setq ss(ssget )) (JMC:COPYPASTE ss) (princ) ) (defun JMC:COPYPASTE ( SB_Selection / FA_BlkObject FA_Attributes FA_Return) (setq SB_FoundSel (ssadd)) (setq SB_Count 0) (setq SB_Max (sslength SB_Selection)) (while (< SB_Count SB_Max) (setq SB_Ent (ssname SB_Selection SB_Count)) (setq FA_BlkObject (vlax-ename->vla-object (ssname SB_Selection SB_Count))) (if (or (= (vla-get-ObjectName FA_BlkObject) "AcDbMText") (= (vla-get-ObjectName FA_BlkObject)"AcDbText") (= (vla-get-ObjectName FA_BlkObject) "AcDbMLeader") (= (vla-get-ObjectName FA_BlkObject) "AcDbAttributeDefinition") ) (progn (princ "\n") (princ (vla-get-PromptString FA_BlkObject)) (princ "\n") (setq FA_NewObject (vla-copy FA_BlkObject)) (vla-delete FA_BlkObject) ) ) (setq SB_Count (1+ SB_Count)) ) )
943
Common Lisp
.l
30
25.133333
79
0.608123
KupipiKuki/BricsCAD_Lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
caa9eb4ef26779b628f9de9fc4f8f4b21547212b1e76c2b1852f019e242542dc
44,313
[ -1 ]
44,314
PurgeAll.lsp
KupipiKuki_BricsCAD_Lisp/PurgeAll.lsp
;Modified by JCHEERS ;Written by Mark and Modified by Kevin Nehls on the Autodesk forums ; ;****************************************************************** (defun C:PURGEALL (/ Count ttlCount) (setq Count 0) (setq ttlCount 0 ) (while (/= 0 (setq Count ( (lambda (/ Count) (setq Count 0) (command "._-PURGE" "_A" "*" "Y") (while (not (zerop (getvar "CMDACTIVE"))) (command "_Y") (setq Count (1+ Count)) ) Count ) ) ) ) (setq ttlCount (+ ttlCount Count)) ) (if (/= ttlCount 0) (princ (strcat "\nPurge completed, total of " (itoa ttlCount) " item(s) purged." ) ) (princ "\nNothing to purge.") ) (princ) )
750
Common Lisp
.l
36
15.805556
68
0.482517
KupipiKuki/BricsCAD_Lisp
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
bf3b4623dbd29e852f09022627d21fe2a9062b455d155890944c5034fb6245c9
44,314
[ -1 ]
44,335
scratch.lisp
kirollos-ha_lisp-html/scratch.lisp
(defstruct (tagspec (:constructor tag)) "tutto quello che il sistema sa di una tag viene dallo struct tag associato, tutto" ;; poi allo struct andaranno aggiunte, tra le altre cose ;; - check da fare sui parametri alla generazione ;; - "hint" per la stampa, ovvero dove mettere i newline ;; - vedi poi sym empty-p) (defun tagspec-name (spec) (string-downcase (symbol-name (tagspec-sym spec)))) (defparameter *html-tags-spec* (list (tag :sym 'h1 :empty-p nil) (tag :sym 'h2 :empty-p nil) (tag :sym 'h3 :empty-p nil) (tag :sym 'h4 :empty-p nil) (tag :sym 'h5 :empty-p nil) (tag :sym 'p :empty-p nil) (tag :sym 'ul :empty-p nil) (tag :sym 'li :empty-p nil) (tag :sym 'div :empty-p nil) (tag :sym 'a :empty-p nil) (tag :sym 'img :empty-p t) (tag :sym 'br :empty-p t))) (defun maybe-first-kwarg (lst) "got a bit too untestable to stay as a single labels preamble returns first key-arg pair it that's possible, nil otherwise" (and (keywordp (car lst)) (consp (cdr lst)) (cons (string-downcase (symbol-name (car lst))) (cadr lst)))) (defun split-kwargs (body) "returns (values <kwargs> <body>) from a list (append <kwargs> <body>), kwargs are returned as an alist of (cons key val), where key and string are lists" (let ((kwargs nil)) (do ((lst body (cddr lst))) (()) (let ((kwarg (maybe-first-kwarg lst))) (if kwarg (push kwarg kwargs) (return-from split-kwargs (values (nreverse kwargs) lst))))))); lst qui prima sine (defun should-print-p (elt) "should the value inserted in the tag be printed or evaluated without printing? (feature used to avoid littering the tag writing with prints and formats)" (or (stringp elt) (numberp elt) (characterp elt))) (defmacro with-tag (tagname body &key (opening-tag-open-fmt "<~a") (opening-tag-close-fmt ">") (closing-tag-open-fmt "</~a") (closing-tag-close-fmt ">~%")) "generates code to print the tagbody inside of a <tagname> ... </tagname> element" (let ((childsym (gensym "child")) (keysym (gensym "key")) (valsym (gensym "val"))) (multiple-value-bind (tag-attrs tag-body) (split-kwargs body) (print tag-attrs) (print tag-body) `(progn (html-format ,opening-tag-open-fmt ,tagname) ;; print tag attributes : ;; using let allows us to have variable lookup be done at runtime ;; thus using rutime values to be used in the generated html ,@(mapcar (lambda (x) `(let ((,keysym ,(car x)) (,valsym ,(cdr x))) (html-format " ~a=\"~a\"" ,keysym ,valsym))) tag-attrs) (html-format ,opening-tag-close-fmt) ;; same construct as the tags ,@(mapcar (lambda (x) `(let ((,childsym ,x)) (when (should-print-p ,childsym) (html-format "~a" ,childsym)))) tag-body) (html-format ,closing-tag-open-fmt ,tagname) (html-format ,closing-tag-close-fmt))))) (defmacro with-empty-tag (tagname body) "generates the code to print an \"empty\" <tagname (attr=something)*/> element" `(with-tag ,tagname ,body :opening-tag-close-fmt "/>~%" :closing-tag-open-fmt "" :closing-tag-close-fmt "")) (defparameter *html-out-stream* nil) (defparameter *default-html-out-stream* *standard-output*) ;; this one's a macro because i don't want to touch format's arglist (defmacro html-format (&rest body) `(format *html-out-stream* ,@body)) (defmacro deftag (tag) (let ((tagname (string-downcase (symbol-name tag)))) `(defmacro ,tag (&rest body) `(with-tag ,,tagname ,body)))) (defmacro def-empty-tag (tag) (let ((tagname (string-downcase (symbol-name tag)))) `(defmacro ,tag (&rest body) `(with-empty-tag ,,tagname ,body)))) (defmacro with-tags (&rest body) `(let ((*html-out-stream* (or *html-out-stream* *default-out-stream*))) (macrolet ,(generate-tag-macrolets) ,@ body))) (defun generate-tag-macrolets () "uses *html-tags-spec* to create variable assignments for a macrolet that will put all tags in a local environment, as to not define h1, li, div, et al. globally when this code is used, and to avoid wirting (tags:ul (tags: li \"hello\") (tags:li \"world\")) when this goes in a sseparate package" (mapcar #'single-tag-macrolet-from-spec *html-tags-spec*)) (defun single-tag-macrolet-from-spec (spec) "generates a single assigment in the macrolet, using a single tagspec from the list, though the name might be un po' too much" (let ((tagname (tagspec-name spec))) `(,(tagspec-sym spec) (&rest body) `(,(if ,(tagspec-empty-p spec) 'with-empty-tag 'with-tag) ,,tagname ,body)))) #| (defmacro maplet ()) ;; sintassi questa (maplet (((,keysym) ,(car x)) ((,valsym) ,(cdr x))) (format t "..." ,keysym ,valsym) tag-attrs) ;; dovrebbe espandersi a questa (mapcar (lambda (x) `(let ((,keysym ,(car x)) (,valsym ,(cdr x))) (format t "~A=\"~A\"" ,keysym ,valsym))) tag-attrs) |#
4,964
Common Lisp
.lisp
119
37.428571
298
0.656231
kirollos-ha/lisp-html
0
0
0
GPL-2.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
9ab86696200e7a467e57731facf10c9c6a4cc973eb0a06ed4c7bb18e01e8e2d8
44,335
[ -1 ]
44,352
main.lisp
bmansurov_cl-foma/src/main.lisp
(defpackage cl-foma (:use :cl) (:export :make-fst :apply-down :apply-up :apply-lower-words :apply-upper-words :apply-words :apply-random-lower :apply-random-upper :apply-random-words)) (in-package :cl-foma) (cffi:define-foreign-library libfoma (:unix (:or "libfoma.so.0.9.18" "libfoma.so")) (t (:default "libfoma"))) (cffi:use-foreign-library libfoma) (cffi:defcstruct fsm (name :string) (arity :int) (arccount :int) (statecount :int) (linecount :int) (finalcount :int) (pathcount :long-long) (is_deterministic :int) (is_pruned :int) (is_minimized :int) (is_epsilon_free :int) (is_loop_free :int) (is_completed :int) (arcs_sorted_in :int) (arcs_sorted_out :int) (fsm-state :pointer) (sigma :pointer) (medlookup :pointer)) (cffi:defcfun ("fsm_parse_regex" foma-fsm-parse-regex) (:pointer (:struct fsm)) (regex :string) (defined-networks :pointer) (defined-functions :pointer)) (cffi:defcfun ("fsm_read_binary_file" foma-fsm-read-binary-file) (:pointer (:struct fsm)) (filename :string)) (cffi:defcfun ("apply_init" foma-apply-init) :pointer (fsm :pointer (:struct fsm))) (cffi:defcfun ("apply_clear" foma-apply-clear) :void (apply-handle :pointer)) (cffi:defcfun ("apply_down" foma-apply-down) :string (apply-handle :pointer) (word :string)) (cffi:defcfun ("apply_up" foma-apply-up) :string (apply-handle :pointer) (word :string)) (cffi:defcfun ("apply_lower_words" foma-apply-lower-words) :string (apply-handle :pointer)) (cffi:defcfun ("apply_upper_words" foma-apply-upper-words) :string (apply-handle :pointer)) (cffi:defcfun ("apply_words" foma-apply-words) :string (apply-handle :pointer)) (cffi:defcfun ("apply_random_lower" foma-apply-random-lower) :string (apply-handle :pointer)) (cffi:defcfun ("apply_random_upper" foma-apply-random-upper) :string (apply-handle :pointer)) (cffi:defcfun ("apply_random_words" foma-apply-random-words) :string (apply-handle :pointer)) (defclass fst-network-definitions () ((handle :initform (cffi:foreign-funcall "defined_networks_init" :pointer)))) (defclass fst-function-definitions () ((handle :initform (cffi:foreign-funcall "defined_functions_init" :pointer)))) (defclass fst () ((network-definitions :reader fst-network-definitions :initform (make-instance 'fst-network-definitions)) (function-definitions :reader fst-function-definitions :initform (make-instance 'fst-function-definitions)) (handle :accessor fst-handle))) (defmethod initialize-instance :after ((fst fst) &key (filename nil filename-supplied-p) (regex nil regex-supplied-p)) (when (and filename-supplied-p regex-supplied-p) (error "Supply either FILENAME or REGEX, but not both.")) (when filename-supplied-p (load-binary-file fst filename)) (when regex-supplied-p (setf (fst-handle fst) (foma-fsm-parse-regex regex (fst-network-definitions fst) (fst-function-definitions fst))) (unless (fst-handle fst) (error "Syntax error in regex.")))) #+nil (defparameter *fst* (make-instance 'fst :filename "/path/to/morphology.bin")) (defun make-fst (&key filename regex) (when (and filename regex) (error "Supply either FILENAME or REGEX, but not both.")) (cond (filename (make-instance 'fst :filename filename)) (regex (make-instance 'fst :regex regex)) (t nil))) (defmethod load-binary-file ((fst fst) filename) (setf (slot-value fst 'handle) (foma-fsm-read-binary-file filename)) (unless (slot-value fst 'handle) (error "Could not load file ~A." filename)) fst) #+nil (load-binary-file *fst* "/path/to/morphology.bin") (defun apply% (function fst &optional word) (unless (slot-value fst 'handle) (error "FST is not defined.")) (loop with apply-handle = (foma-apply-init (slot-value fst 'handle)) ;; apply-{upper,lower}-words potentially generate infinite ;; number of words, thus limit here: for i from 0 below 100 for output = (if word (funcall function apply-handle word) (funcall function apply-handle)) then (if word (funcall function apply-handle (cffi:null-pointer)) (funcall function apply-handle)) while output collect output into results finally (progn (foma-apply-clear apply-handle) (return-from apply% results)))) (defun apply-down (fst word) (apply% #'foma-apply-down fst word)) #+nil (apply-down *fst* "ол+VERB+Act+Neg+Pure+Fut+2pSg+Imp") (defun apply-up (fst word) (apply% #'foma-apply-up fst word)) #+nil (apply-up *fst* "олма") (defun apply-lower-words (fst) (apply% #'foma-apply-lower-words fst)) #+nil (print (apply-lower-words *fst*)) (defun apply-upper-words (fst) (apply% #'foma-apply-upper-words fst)) #+nil (print (apply-upper-words *fst*)) (defun apply-words (fst) (apply% #'foma-apply-words fst)) #+nil (print (apply-words *fst*)) (defun apply-random-lower (fst) (apply% #'foma-apply-random-lower fst)) #+nil (print (apply-random-lower *fst*)) (defun apply-random-upper (fst) (apply% #'foma-apply-random-upper fst)) #+nil (print (apply-random-upper *fst*)) (defun apply-random-words (fst) (apply% #'foma-apply-random-words fst)) #+nil (print (apply-random-words *fst*))
5,533
Common Lisp
.lisp
162
29.271605
70
0.670163
bmansurov/cl-foma
0
0
0
LGPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
337c4620f2c1450f0d629b7f9ec0c21497b69553281beb4ad5cd40a15f717513
44,352
[ -1 ]
44,353
main.lisp
bmansurov_cl-foma/tests/main.lisp
(defpackage cl-foma/tests/main (:use :cl :cl-foma :rove)) (in-package :cl-foma/tests/main) ;; NOTE: To run this test file, execute `(asdf:test-system :cl-foma)' in your Lisp. (deftest test-target-1 (testing "should (= 1 1) to be true" (ok (= 1 1))))
276
Common Lisp
.lisp
9
26.777778
83
0.630189
bmansurov/cl-foma
0
0
0
LGPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
a8f8577b3ac825b9f0ed58c857c521ccb84e4c41c1088c96703f7855740d1739
44,353
[ -1 ]
44,354
cl-foma.asd
bmansurov_cl-foma/cl-foma.asd
(defsystem "cl-foma" :version "0.1.0" :author "bmansurov" :license "lgpl-3" :depends-on ("cffi") :components ((:module "src" :components ((:file "main")))) :description "Common Lisp bindings for Foma" :in-order-to ((test-op (test-op "cl-foma/tests")))) (defsystem "cl-foma/tests" :author "bmansurov" :license "LGPL-3" :depends-on ("cl-foma" "rove") :components ((:module "tests" :components ((:file "main")))) :description "Test system for cl-foma" :perform (test-op (op c) (symbol-call :rove :run c)))
609
Common Lisp
.asd
20
24.15
55
0.576531
bmansurov/cl-foma
0
0
0
LGPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
08017c221ae208ea4e915d03665ce18f147485da6c56feb941121ce0abce959e
44,354
[ -1 ]
44,373
essentials-of-lisp.md
Neshamon_simple-database/essentials-of-lisp.md
<a id="x-28SIMPLE-DB-3A-40ESSENTIALS-OF-LISP-20MGL-PAX-3ASECTION-29"></a> <a id="SIMPLE-DB:@ESSENTIALS-OF-LISP%20MGL-PAX:SECTION"></a> # Essentials of Lisp ## Table of Contents - [1 The Basics][3e78] - [2 The Basics of the Basics][77a6] - [3 Flow of Execution][0fd9] - [4 Symbols][b896] ###### \[in package SIMPLE-DB\] <a id="x-28SIMPLE-DB-3AMAKE-CD-20FUNCTION-29"></a> <a id="SIMPLE-DB:MAKE-CD%20FUNCTION"></a> - [function] **MAKE-CD** *TITLE ARTIST RATING RIPPED* Creates a record <a id="x-28SIMPLE-DB-3A-2ADB-2A-20VARIABLE-29"></a> <a id="SIMPLE-DB:*DB*%20VARIABLE"></a> - [variable] **\*DB\*** *"Creates a db"* <a id="x-28SIMPLE-DB-3A-40THE-BASICS-20MGL-PAX-3ASECTION-29"></a> <a id="SIMPLE-DB:@THE-BASICS%20MGL-PAX:SECTION"></a> ## 1 The Basics The first function is a function that creates records. It takes these values as arguments: - title - artist - rating - ripped After taking these values the function then creates a list of keywords and the given parameters specified above. But you might ask how Lisp knows how or even *when* to do this. To understand this, let's take a step back to look at some fundamentals of Common Lisp <a id="x-28SIMPLE-DB-3A-40THE-BASICS-OF-THE-BASICS-20MGL-PAX-3ASECTION-29"></a> <a id="SIMPLE-DB:@THE-BASICS-OF-THE-BASICS%20MGL-PAX:SECTION"></a> ## 2 The Basics of the Basics The fundamental building block of everything in Lisp is the *S-Expression*. *S-Expressions*, or sexprs, are the representation of objects within Common Lisp; Any and everything in Lisp is an object. These sexprs can be represented in two main ways, as an `atom`([`0`][5152] [`1`][a657]) or a basic type of *list* called a `cons`([`0`][a237] [`1`][12a8]) Now you may be wondering why there are so many parentheses in Common Lisp. The reason why is because of the `cons` data structure. Lists in Lisp are delimited by parentheses. You can verify this by running these functions in a sbcl lisp repl: ```lisp CL-USER> (consp (list :title 'title :artist 'artist :rating 'rating :ripped 'ripped)) ``` ```lisp CL-USER> (listp (list :title 'title :artist 'artist :rating 'rating :ripped 'ripped)) ``` The functions [`listp`][fefd] and [`consp`][6d19] check if the given value or sequence is a list/cons respectively and returns `T` (Lisp's version of true) or `nil` (Lisp's false) otherwise. These functions also show something else that's important. Even though we tested the same sequence, they both returned `T`, meaning that we can know that a `cons` is a `list`([`0`][79d8] [`1`][6d9f]) and a `list` is a `cons` Knowing this, it's quite easy to see how everything in Lisp is made up of lists. But where exactly does the `cons` list fit in among all these lists? The `cons` list is the most fundamental list, it consists of a pair of two values and can be denoted as: `( value1 . value2 )` And nearly everything in Common Lisp is represented by these `cons` lists. If you run this function in the lisp repl, you can see how a cons list and a regular list are equal: ```lisp CL-USER> (equal (list :title 'title :artist 'artist :rating 'rating :ripped 'ripped) (cons :title (cons 'title (cons :artist (cons 'artist (cons :rating (cons 'rating (cons :ripped (cons 'ripped '()))))))))) ``` Wow! That's a lot to take in isn't it? What is essentially happening in this function is the [`list`][6d9f] function is turning the sequence of values into a list. The second portion of this comparison is the chain of *conses*. Like I said earlier, a `cons` is a pair of two values. This is well represented in this large function when you understand how the [`cons`][12a8] function works. The [`cons`][12a8] function creates a `cons` list by pairing the first argument to the second argument. This is why you see me chaining all of them together in order to get a long enough list to fit 8 values. Even at the last sexpr of the `cons` chain, you can see me pair `'ripped` with an empty set of parentheses. This shows that `cons` will always take two arguments and not any less. The third part of this function is at the beginning, where we have our [`equal`][3fb5] operator. `Equal` takes two arguments and returns `T` if the two objects are equal and `nil` otherwise. If you evaluate this function you will see that it returns `T`, meaning that these two lists are equal. Isn't that odd? These two lists don't look remotely the same! Not only that, Why does the value `equal` at the beginning execute, but the value `:title` or any other value in these lists not execute? <a id="x-28SIMPLE-DB-3A-40FLOW-OF-EXECUTION-20MGL-PAX-3ASECTION-29"></a> <a id="SIMPLE-DB:@FLOW-OF-EXECUTION%20MGL-PAX:SECTION"></a> ## 3 Flow of Execution If Lisp were to have any type of concrete syntax, it would be this. Every list in Lisp follows a syntax similar to this: ```lisp (<operator> <arg1> <arg2> ... <argn>) ``` You can see this pattern in every function call to `cons`([`0`][a237] [`1`][12a8]) and in the call to `list`([`0`][79d8] [`1`][6d9f]) as well. Because an operator or function will usually always be at the beginning of a list. This operator is applied to every argument that comes after it. It's a little difficult to understand how the [`equal`][3fb5] operater applies to each argument, so let's look at an easier example: ```lisp (+ 1 2) ``` This is simple addition between two integers in Lisp. In the same way we would add 1 to 2 to get a sum of three, so would we apply the operator of `equal` to each argument in the previous functions. Another way to look at it would be this way: ```lisp (+ 1 2 3 4 5 6 7 8 9) ; => 45 (+ (+ 1 2) (+ 3 4) (+ 5 6) (+ 7 8) 9) ; => 45 (+ 3 7 11 15 9) ; => 45 (+ (+ 3 7) (+ 11 15) 9) ; => 45 (+ 10 26 9) ; => 45 (+ (+ 10 26) 9) ; => 45 (+ 36 9) ; => 45 45 ; This is an atom ``` When you look at the code above, you can see how the addition operator is applied to its arguments in pairs. For every pair of arguments we are performing the operation of addition. In the same way in which we perform addtion on the arguments of the addition operator, so would we any other operator. So the equal operator would look something like this: ```lisp (equal (equal 1 (equal 1 (equal 2 "2"))) (equal 1 (equal 1 (equal 2 "2")))) ; => T (equal (equal 1 (equal 1 nil)) (equal 1 (equal 1 nil))) ; => T (equal (equal 1 nil) (equal 1 nil)) ; => T (equal nil nil) ; => T T ``` Now after looking a little closer at these two functions, wouldn't you say that this looks a little familiar? If we refer back to our `cons` list, we would see a similar pattern of function calls whether it's the addition operator or the equals operator. For addition it would look like: ```lisp (+ 1 (+ 2 (+ 3 (+ 4 (+ 5 (+ 6 (+ 7 (+ 8 9)))))))) ;; Or (equal (equal 1 (equal 1 (equal 2 "2"))) (equal 1 (equal 1 (equal 2 "2")))) ``` If you look closely at these functions and how we structured them, you'll notice we presented the same result in multiple ways; Every iteration of the addition sexprs were all different ways to say the same thing. But what if I told you this phenomena was going on in more ways than one? <a id="x-28SIMPLE-DB-3A-40SYMBOLS-20MGL-PAX-3ASECTION-29"></a> <a id="SIMPLE-DB:@SYMBOLS%20MGL-PAX:SECTION"></a> ## 4 Symbols Let's go back to our variable [`*db*`][4363] and let me show you something interesting: ```lisp (defparameter *db* 33) (defun *db* (*db*) (+ *db* *db*)) (*db* *db*) (function-lambda-expression (symbol-function '*db*)) ``` After looking at this code, do you think something like this would work? Or is the lisp repl just going to throw errors at us concerning names? Well if you guessed that it would work, then you'd be correct What's going on is that a global variable called `*db*` is created with the value of 33. After that a function also with the name of `*db*`. . . Wait what? How can a function share the name of `*db*` with a variable simultaneously? This is because of a data type called a symbol As we discussed before, everything in Common Lisp is made up of **Sexprs**, which represent objects. We also know that these Sexprs can either be categorized as atoms or cons cells/lists/singly linked lists. But there is one more fundamental representation we ought to talk about, and it's a [`symbol`][e5af] In Algol-based languages (Languages like C), the primitive or composite data type is typically a string literal This is just one fraction of incredible amount flexibility you get when it comes to writing any program in Lisp. In non-Lisp languages there is usually always a stricter syntax that guides the user to program in a specific way. With Lisp, the flexible syntax imposes very few restrictions on how you may want to write your program. [0fd9]: #SIMPLE-DB:@FLOW-OF-EXECUTION%20MGL-PAX:SECTION "Flow of Execution" [12a8]: http://www.lispworks.com/documentation/HyperSpec/Body/f_cons.htm "CONS (MGL-PAX:CLHS FUNCTION)" [3e78]: #SIMPLE-DB:@THE-BASICS%20MGL-PAX:SECTION "The Basics" [3fb5]: http://www.lispworks.com/documentation/HyperSpec/Body/f_equal.htm "EQUAL (MGL-PAX:CLHS FUNCTION)" [4363]: #SIMPLE-DB:*DB*%20VARIABLE "SIMPLE-DB:*DB* VARIABLE" [5152]: http://www.lispworks.com/documentation/HyperSpec/Body/f_atom.htm "ATOM (MGL-PAX:CLHS FUNCTION)" [6d19]: http://www.lispworks.com/documentation/HyperSpec/Body/f_consp.htm "CONSP (MGL-PAX:CLHS FUNCTION)" [6d9f]: http://www.lispworks.com/documentation/HyperSpec/Body/f_list_.htm "LIST (MGL-PAX:CLHS FUNCTION)" [77a6]: #SIMPLE-DB:@THE-BASICS-OF-THE-BASICS%20MGL-PAX:SECTION "The Basics of the Basics" [79d8]: http://www.lispworks.com/documentation/HyperSpec/Body/t_list.htm "LIST (MGL-PAX:CLHS CLASS)" [a237]: http://www.lispworks.com/documentation/HyperSpec/Body/t_cons.htm "CONS (MGL-PAX:CLHS CLASS)" [a657]: http://www.lispworks.com/documentation/HyperSpec/Body/t_atom.htm "ATOM (MGL-PAX:CLHS TYPE)" [b896]: #SIMPLE-DB:@SYMBOLS%20MGL-PAX:SECTION "Symbols" [e5af]: http://www.lispworks.com/documentation/HyperSpec/Body/t_symbol.htm "SYMBOL (MGL-PAX:CLHS CLASS)" [fefd]: http://www.lispworks.com/documentation/HyperSpec/Body/f_listp.htm "LISTP (MGL-PAX:CLHS FUNCTION)"
10,622
Common Lisp
.lisp
181
54.966851
133
0.698244
Neshamon/simple-database
0
0
0
AGPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
d03eb017c4bc446121a0bd465a2c86cc401863a7fbd9b2d4177b7b3f243d3770
44,373
[ -1 ]
44,390
main.lisp
fmqa_oascg/typescript/tests/main.lisp
(defpackage #:oascg-typescript-tests (:use :cl :fiveam) (:export #:run! #:oascg-typescript)) (in-package #:oascg-typescript-tests) (def-suite oascg-typescript) (in-suite oascg-typescript) (test test-basic-types-any (let* ((json "{}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "unknown" (oascg-typescript:typescript schema))))) (test test-basic-types-number (let* ((json "{\"type\": \"number\"}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "number" (oascg-typescript:typescript schema))))) (test test-basic-types-number-nullable (let* ((json "{\"type\": \"number\", \"nullable\": true}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "number | null" (oascg-typescript:typescript schema))))) (test test-basic-types-string (let* ((json "{\"type\": \"string\"}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "string" (oascg-typescript:typescript schema))))) (test test-string-enum (let* ((json "{\"type\": \"string\", \"enum\":[\"a\",\"b\"]}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "\"a\"|\"b\"" (oascg-typescript:typescript schema))))) (test test-array (let* ((json "{\"type\": \"array\", \"items\":{\"type\": \"number\"}}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "Array<number>" (oascg-typescript:typescript schema))))) (test test-object (let* ((json "{\"type\": \"object\", \"properties\":{\"a\": {\"type\": \"number\"}}}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "{a?: number;}" (oascg-typescript:typescript schema))))) (test test-object-required (let* ((json "{\"type\": \"object\", \"required\": [\"a\"], \"properties\":{\"a\": {\"type\": \"number\"}}}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "{a: number;}" (oascg-typescript:typescript schema))))) (test test-comb-allof-objects (let* ((json-a "{\"type\": \"object\", \"required\": [\"a\"], \"properties\":{\"a\": {\"type\": \"number\"}}}") (json-b "{\"type\": \"object\", \"required\": [\"b\"], \"properties\":{\"b\": {\"type\": \"string\"}}}") (json (format nil "{\"allOf\": [~A, ~A]}" json-a json-b)) (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "{a: number;} & {b: string;}" (oascg-typescript:typescript schema))))) (test test-comb-anyof-objects (let* ((json-a "{\"type\": \"object\", \"required\": [\"a\"], \"properties\":{\"a\": {\"type\": \"number\"}}}") (json-b "{\"type\": \"object\", \"required\": [\"b\"], \"properties\":{\"b\": {\"type\": \"string\"}}}") (json (format nil "{\"anyOf\": [~A, ~A]}" json-a json-b)) (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "{a: number;} | {b: string;}" (oascg-typescript:typescript schema))))) (test test-comb-oneof-objects (let* ((json-a "{\"type\": \"object\", \"required\": [\"a\"], \"properties\":{\"a\": {\"type\": \"number\"}}}") (json-b "{\"type\": \"object\", \"required\": [\"b\"], \"properties\":{\"b\": {\"type\": \"string\"}}}") (json (format nil "{\"oneOf\": [~A, ~A]}" json-a json-b)) (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht))) (is (string= "{a: number;} | {b: string;}" (oascg-typescript:typescript schema))))) (test test-comb-allof-objects-nested (let* ((json-a "{\"type\": \"object\", \"required\": [\"a\"], \"properties\":{\"a\": {\"type\": \"number\"}}}") (json-b "{\"type\": \"object\", \"required\": [\"b\"], \"properties\":{\"b\": {\"type\": \"string\"}}}") (json-c "{\"type\": \"object\", \"properties\": {\"xyz\": {\"type\": \"string\"}}}") (one-of-a (format nil "{\"oneOf\": [~A, ~A]}" json-a json-b)) (one-of-b (format nil "{\"oneOf\": [~A, ~A]}" json-a json-b)) (all-of (format nil "{\"allOf\": [~A, ~A, ~A]}" one-of-a one-of-b json-c)) (ht (com.inuoe.jzon:parse all-of)) (schema (oascg-core:schema-from-ht ht))) (is (string= "({a: number;} | {b: string;}) & ({a: number;} | {b: string;}) & {xyz?: string;}" (oascg-typescript:typescript schema))))) (test test-object-export-one (let* ((json "{\"type\": \"object\", \"properties\":{\"a\": {\"type\": \"number\"}}}") (components (format nil "{\"first\": ~A}" json)) (ht (com.inuoe.jzon:parse components))) (is (equal (list "export interface first {a?: number;}") (oascg-typescript:export-typescript-components ht))))) (test test-object-export-two (let* ((one "{\"type\": \"object\", \"properties\":{\"a\": {\"type\": \"number\"}}}") (two "{\"type\": \"string\", \"enum\":[\"a\",\"b\"]}") (components (format nil "{\"first\": ~A, \"second\": ~A}" one two)) (ht (com.inuoe.jzon:parse components))) (is (equal (list "export interface first {a?: number;}" "export type second = \"a\"|\"b\"") (oascg-typescript:export-typescript-components ht))))) (test test-component-ref (let* ((one "{\"type\": \"object\", \"properties\":{\"a\": {\"type\": \"number\"}}}") (two "{\"type\": \"array\", \"items\":{\"$ref\": \"#/components/schemas/first\"}}") (components (format nil "{\"first\": ~A, \"second\": ~A}" one two)) (ht (com.inuoe.jzon:parse components))) (is (equal (list "export interface first {a?: number;}" "export type second = Array<first>") (oascg-typescript:export-typescript-components ht))))) (test test-component-ref-nested (let* ((one "{\"type\": \"object\", \"required\":[\"b\"], \"properties\":{\"a\": {\"type\": \"number\"}, \"b\": {\"$ref\": \"#/components/schemas/third\"}}}") (two "{\"type\": \"array\", \"items\":{\"$ref\": \"#/components/schemas/first\"}}") (three "{\"type\": \"integer\"}") (components (format nil "{\"first\": ~A, \"second\": ~A, \"third\": ~A}" one two three)) (ht (com.inuoe.jzon:parse components))) (is (equal (list "export interface first {a?: number;b: third;}" "export type second = Array<first>" "export type third = number") (oascg-typescript:export-typescript-components ht)))))
6,675
Common Lisp
.lisp
110
53.290909
160
0.540024
fmqa/oascg
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
616f31b5d89a50da66eb1e902b48adca9f24e10fe25fea62b677443855759e41
44,390
[ -1 ]
44,391
main.lisp
fmqa_oascg/core/src/main.lisp
;; OAS CODE GENERATOR - CORE DATA STRUCTURES & FUNCTIONS ;; ;; This module contains functions for converting OAS structures to concrete COMMON LISP types. ;; ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |OAS TYPE |CLASS |SLOTS |DESCRIPTION | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |integer |SIMPLE-SCHEMA|:type :integer |- | ;; | | | | | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |number |SIMPLE-SCHEMA|:type :number |- | ;; | | | | | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |string |SIMPLE-SCHEMA|:type :string |- | ;; | | | | | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |boolean |SIMPLE-SCHEMA|:type :boolean |- | ;; | | | | | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |array |ARRAY-SCHEMA |:items SCHEMA |SCHEMA is the schema of the array | ;; | | | |element(s) | ;; | | | | | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |object |OBJECT-SCHEMA|:properties HASH-TABLE |HASH-TABLE is a | ;; | | | | | ;; | | | |PROPERTY-NAME -> (SCHEMA . REQUIRED) | ;; | | | | | ;; | | | |mapping. | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |$ref |REF-SCHEMA |:uri URI |URI is a STRING referencing a local | ;; | | |:resolved SCHEMA-OR-NIL |or remote schema object. | ;; | | | | | ;; | | | |If SCHEMA-OR-NIL is non-NIL, the | ;; | | | |schema is resolved. Otherwise, the | ;; | | | |schem is unresolved | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |anyOf |COMB-SCHEMA |:op :any-of |- | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |oneOf |COMB-SCHEMA |:op :one-of |- | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; |allOf |COMB-SCHEMA |:op :all-of |- | ;; +--------------+-------------+------------------------+--------------------------------------+ ;; ;; An abstract factory SCHEMA-FROM-HT is provided to translate from deserialized ;; OAS datums (represented as hash tables) into objects of one of the previous ;; classes. (defpackage oascg-core (:use :cl) (:export #:unresolved-schema-error #:unresolved-schema-uri #:nullable-schema #:schema-nullable #:simple-schema #:simple-schema-type #:simple-schema-format #:simple-schema-enum #:array-schema #:array-schema-items #:object-schema #:object-schema-properties #:ref-schema #:ref-schema-uri #:ref-schema-resolved #:schema-ref-resolve #:schema-ensure-resolved #:discriminated-property #:discriminated-property-name #:discriminated-property-mapping #:comb-schema #:comb-schema-op #:comb-schema-operands #:comb-schema-discriminator #:component #:component-name #:component-schema #:component-ensure-schema #:make-component #:register-component-schema #:register-components-from-ht #:with-components-from-ht #:map-components #:resolve-local-component-by-uri #:resolve-local-component-handler #:schema-iterator #:schema-unboundedp #:schema-from-ht)) (in-package :oascg-core) ;;;;;; ;;;;;; PARAMETERS ;;;;;; ;; Should be bound to a hash table representing the relationship ;; ;; COMPONENT-NAME -> COMPONENT ;; ;; Where SCHEMA-NAME is a STRING and COMPONENT is a COMPONENT object. (defparameter *components* nil "Components by name.") ;;;;;; ;;;;;; CONDITIONS ;;;;;; ;; UNRESOLVED-SCHEMA-ERROR is signalled when a schema could not be resolved. ;; The caller can invoke the restarts ;; ;; USE-VALUE to use the given value as a replacement schema. ;; CONTINUE to ignore the error. ;; (define-condition unresolved-schema-error (error) ((uri :initarg :uri :reader unresolved-schema-uri :documentation "URI of the unresolved schema."))) ;;;;;; ;;;;;; DATA TYPES ;;;;;; ;; Superclass for schemas that have the 'nullable' OAS property. ;; This included integer, number, string, array, object schemas, as well ;; as the unbounded schema. (defclass nullable-schema () ((nullable :initarg :nullable :accessor schema-nullable :initform nil :documentation "Indicates whether schema is nullable."))) ;; Scalar schema type. (defclass simple-schema (nullable-schema) ((type :initarg :type :accessor simple-schema-type :documentation "Schema type.") (format :initarg :format :accessor simple-schema-format :initform nil :documentation "Schema format.") (enum :initarg :enum :accessor simple-schema-enum :initform nil :documentation "Enumeration vector."))) ;; Array schema type. (defclass array-schema (nullable-schema) ((items :initarg :items :accessor array-schema-items :documentation "Schema of array elements."))) ;; Object schema type. (defclass object-schema (nullable-schema) ((properties :initarg :properties :accessor object-schema-properties :initform (make-hash-table :test 'equal) :documentation "Schema of each property, by property name."))) ;; $ref pseudo-schema type. (defclass ref-schema () ((uri :initarg :uri :accessor ref-schema-uri :documentation "Reference target URI.") (resolved :initarg :resolved :accessor ref-schema-resolved :initform nil :documentation "Resolved target schema."))) ;; Sum type discriminator. (defclass discriminated-property () ((name :initarg :property-name :accessor discriminated-property-name :documentation "Discriminator property name.") (mapping :initarg :mapping :accessor discriminated-property-mapping :initform nil :documentation "Maps property values to schemas."))) ;; Combinatoric pseudo-schema. ;; ;; This represents allOf, oneOf, and anyOf schemas. (defclass comb-schema () ((op :initarg :op :accessor comb-schema-op :documentation "Schema combinator operator.") (operands :initarg :operands :accessor comb-schema-operands :documentation "Schemas to combine.") (discriminator :initarg :discriminator :accessor comb-schema-discriminator :initform nil :documentation "Sum type discriminator property."))) ;; Named component schema type. (defclass component () ((name :initarg :name :accessor component-name :documentation "Component name.") (schema :initarg :schema :accessor component-schema :initform nil :documentation "Component schema or schema factory."))) ;;;;;; ;;;;;; PROCEDURES ;;;;;; ;; GENERIC SCHEMA PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric schema-iterator (parent) (:documentation "Returns an iterator function.")) (defmethod schema-iterator ((parent array-schema)) (lambda (it) (funcall it (array-schema-items parent)))) (defmethod schema-iterator ((parent object-schema)) (lambda (it) (when (object-schema-properties parent) (maphash (lambda (name pair) (destructuring-bind (schema &rest required) pair (funcall it schema name required))) (object-schema-properties parent))))) (defgeneric schema-unboundedp (schema) (:documentation "Tests whether a given schema is unbounded")) (defmethod schema-unboundedp (schema) nil) (defmethod schema-unboundedp ((schema object-schema)) (and (object-schema-properties schema) (= 0 (hash-table-count (object-schema-properties schema))))) ;; COMPONENT PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Returns the schema of a COMPONENT object, ensuring that a lazy schema is ;; evaluated. (defun component-ensure-schema (comp) (if (functionp (component-schema comp)) (setf (component-schema comp) (funcall (component-schema comp))) (component-schema comp))) ;; Wraps a schema for lazy evaluation. ;; ;; If the given OAS schema is a hash table representing an OAS schema, it is ;; wrapped in a function that returns a schema object when called. ;; ;; Otherwise, it is equivalent to the identity function. (defun wrap-schema (schema) (etypecase schema (hash-table (lambda () (schema-from-ht schema))) (t schema))) ;; Factory for component objects. ;; ;; The schema is wrapped using WRAP-SCHEMA to enable lazy evaluation. (defun make-component (name schema) (make-instance 'component :name name :schema (wrap-schema schema))) ;; Adds the given schema as local component with name NAME under *COMPONENTS*. (defun register-component-schema (name schema) (let ((key (format nil "#/components/schemas/~A" name))) (setf (gethash key *components*) (make-component name schema)))) ;; Given a hash table of the form ;; ;; SCHEMA-NAME -> SCHEMA ;; ;; Registers all SCHEMA objects under *COMPONENTS*. (defun register-components-from-ht (table) (maphash #'register-component-schema table)) ;; Binds *COMPONENTS* to a hash table representing a URI -> COMPONENT ;; shaped registry of OAS components. ;; ;; The registry is populated from the OAS components document represented by ;; the given TABLE. (defun with-components-from-ht (table f) (let ((*components* (make-hash-table :test 'equal))) (register-components-from-ht table) (funcall f))) ;; Calls the given function on every component in the *COMPONENTS* registry. (defun map-components (f) (when *components* (maphash (lambda (name comp) (declare (ignore name)) (funcall f comp)) *components*))) ;; Returns T if the given URI is a local component URI, i.e. ;; if it starts with "#/components/schemas/". (defun local-component-urip (uri) (= 0 (search "#/components/schemas/" uri))) ;; If the given URI is a local component URI, look it up in the ;; *COMPONENTS* registry. ;; Otherwise, return NIL. (defun resolve-local-component-by-uri (uri) (and (local-component-urip uri) (gethash uri *components*))) ;; Creates a handler function for UNRESOLVED-SCHEMA-URI errors. ;; ;; If the URI of the unresolved schema refers to a local component, it is ;; looked up in the *COMPONENTS* registry, and passed as an argument to the ;; USE-VALUE restart. ;; Otherwise, the NEXT function - if given - is called with the URI. ;; ;; If NEXT is given, this implements a "chain of responsibility" for resolving ;; unresolved URIs. (defun resolve-local-component-handler (&optional next) (lambda (unresolved-err) (let* ((uri (unresolved-schema-uri unresolved-err)) (found (resolve-local-component-by-uri uri))) (if found (invoke-restart 'use-value found) (and next (funcall next uri)))))) ;; REF-SCHEMA PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Factory for REF-SCHEMA objects. ;; ;; TABLE should be an OAS hash table / dictionary. (defun schema-ref-from-ht (table) (let ((uri (gethash "$ref" table))) (if uri (make-instance 'ref-schema :uri uri) (error "$ref has no target URI")))) ;; Resolves a REF-SCHEMA object. ;; ;; May signal an UNRESOLVED-SCHEMA-ERROR condition. (defun schema-ref-resolve (schema) (or (ref-schema-resolved schema) (setf (ref-schema-resolved schema) (restart-case (error 'unresolved-schema-error :uri (ref-schema-uri schema)) (use-value (value) :report "Use a new schema" value) (continue () :report "Continue without resolving" nil))))) (defgeneric schema-ensure-resolved (schema) (:documentation "Ensure a schema is resolved")) (defmethod schema-ensure-resolved (schema) schema) (defmethod schema-ensure-resolved ((schema ref-schema)) (schema-ensure-resolved (schema-ref-resolve schema))) ;; SIMPLE-SCHEMA PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Factory for SIMPLE-SCHEMA objects. ;; ;; TABLE should be an OAS hash table / dictionary. (defun schema-simple-from-ht (table type) (let* ((format (gethash "format" table)) (enum (gethash "enum" table)) (nullable (gethash "nullable" table)) (instance (make-instance 'simple-schema :type type :format format :enum enum))) (setf (schema-nullable instance) nullable) instance)) ;; ARRAY-SCHEMA PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Factory for ARRAY-SCHEMA objects. ;; ;; TABLE should be an OAS hash table / dictionary. (defun schema-array-from-ht (table) (let* ((items (gethash "items" table)) (nullable (gethash "nullable" table)) (instance (make-instance 'array-schema :items (schema-from-ht items)))) (setf (schema-nullable instance) nullable) instance)) ;; OBJECT-SCHEMA PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Add a schema P-SCHEMA as a subschema representing a named property ;; NAME to the OBJECT-SCHEMA denoted by O-SCHEMA. (defun object-schema-add-property (o-schema name p-schema &optional required) (setf (gethash name (object-schema-properties o-schema)) (cons p-schema required))) ;; Factory for OBJECT-SCHEMA objects. ;; ;; TABLE should be an OAS hash table / dictionary. (defun schema-object-from-ht (table) (let ((properties (gethash "properties" table)) (required (let ((names (gethash "required" table))) (when names (let ((ht (make-hash-table :test 'equal))) (loop for name across names do (setf (gethash name ht) t)) ht)))) (nullable (gethash "nullable" table)) (instance (make-instance 'object-schema))) (setf (schema-nullable instance) nullable) (when properties (maphash (lambda (name value) (object-schema-add-property instance name (schema-from-ht value) (and required (gethash name required)))) properties)) instance)) ;; DISCRIMINATED-PROPERTY PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun discriminator-from-ht (table) (let ((discriminator (gethash "discriminator" table))) (when discriminator (let ((name (gethash "propertyName" discriminator)) (mapping (gethash "mapping" discriminator))) (when name (make-instance 'discriminated-property :name name :mapping mapping)))))) ;; COMB-SCHEMA PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun comb-type-key (type) (ecase type (:all-of "allOf") (:any-of "anyOf") (:one-of "oneOf"))) ;; Factory for COMB-SCHEMA objects. ;; ;; TABLE should be an OAS hash table / dictionary. (defun schema-comb-from-ht (table type) (let ((schemas (gethash (comb-type-key type) table))) (if schemas (make-instance 'comb-schema :op type :operands (map 'list #'schema-from-ht schemas) :discriminator (discriminator-from-ht table)) (error "Empty ~A schema" type)))) ;; OPENAPI DOCUMENT PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Infers the type of the OAS schema represented by the hash table TABLE. ;; Returns a symbol representing the inferred type. (defun schema-ht-infer-type (table) (labels ((has (key) (gethash key table)) (has= (key expected) (string= expected (has key))) (type= (expected) (has= "type" expected))) (cond ((has "$ref") :ref) ((has "allOf") :all-of) ((has "oneOf") :one-of) ((has "anyOf") :any-of) ((type= "array") :array) ((type= "object") :object) ((type= "number") :number) ((type= "integer") :integer) ((type= "string") :string) ((type= "boolean") :boolean) (t :object)))) ;; Abstract factory for schema objects. ;; ;; TABLE should be an OAS hash table / dictionary. (defun schema-from-ht (table) (let ((inferred-type (schema-ht-infer-type table))) (ecase inferred-type (:ref (schema-ref-from-ht table)) (:array (schema-array-from-ht table)) (:object (schema-object-from-ht table)) ((:number :integer :string :boolean) (schema-simple-from-ht table inferred-type)) ((:all-of :any-of :one-of) (schema-comb-from-ht table inferred-type)))))
19,367
Common Lisp
.lisp
414
41.140097
97
0.517046
fmqa/oascg
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
9df9cdc4fc50eb8b111485bf0e3b6490dd43d372983e3b0a5672c2618130d5c0
44,391
[ -1 ]
44,392
main.lisp
fmqa_oascg/core/tests/main.lisp
(defpackage #:oascg-core-tests (:use :cl :fiveam) (:export #:run! #:oascg-core)) (in-package #:oascg-core-tests) (def-suite oascg-core) (in-suite oascg-core) (test parse-unbounded-schema (let* ((example-json "{}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (identity (oascg-core:schema-unboundedp schema))) (is (not (oascg-core:schema-nullable schema))))) (test parse-unbounded-schema-nullable (let* ((example-json "{\"nullable\": true}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (identity (oascg-core:schema-unboundedp schema))) (is (oascg-core:schema-nullable schema)))) (test parse-string-schema (let* ((example-json "{\"type\": \"string\"}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (typep schema 'oascg-core:simple-schema)) (is (eq :string (oascg-core:simple-schema-type schema))) (is (not (oascg-core:simple-schema-format schema))) (is (not (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema))))) (test parse-string-schema-enum (let* ((example-json "{\"type\": \"string\", \"enum\":[\"a\",\"b\"]}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (typep schema 'oascg-core:simple-schema)) (is (eq :string (oascg-core:simple-schema-type schema))) (is (not (oascg-core:simple-schema-format schema))) (is (equalp #("a" "b") (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema))))) (test parse-number-schema (let* ((example-json "{\"type\": \"number\"}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (typep schema 'oascg-core:simple-schema)) (is (eq :number (oascg-core:simple-schema-type schema))) (is (not (oascg-core:simple-schema-format schema))) (is (not (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema))))) (test parse-integer-schema (let* ((example-json "{\"type\": \"integer\"}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (typep schema 'oascg-core:simple-schema)) (is (eq :integer (oascg-core:simple-schema-type schema))) (is (not (oascg-core:simple-schema-format schema))) (is (not (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema))))) (test parse-integer-schema-format-int32 (let* ((example-json "{\"type\": \"integer\", \"format\": \"int32\"}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (typep schema 'oascg-core:simple-schema)) (is (eq :integer (oascg-core:simple-schema-type schema))) (is (string= "int32" (oascg-core:simple-schema-format schema))) (is (not (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema))))) (test parse-boolean-schema (let* ((example-json "{\"type\": \"boolean\"}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (typep schema 'oascg-core:simple-schema)) (is (eq :boolean (oascg-core:simple-schema-type schema))) (is (not (oascg-core:simple-schema-format schema))) (is (not (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema))))) (test parse-array-schema (let* ((example-json "{\"type\": \"array\", \"items\": {\"type\": \"number\"}}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema))) (is (typep schema 'oascg-core:array-schema)) (is (not (oascg-core:schema-nullable schema))) (funcall (oascg-core:schema-iterator schema) (lambda (schema) (is (typep schema 'oascg-core:simple-schema)) (is (eq :number (oascg-core:simple-schema-type schema))) (is (not (oascg-core:simple-schema-format schema))) (is (not (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema))))))) (test parse-object-schema (let* ((example-json "{\"type\": \"object\", \"required\":[\"a\"], \"properties\": {\"a\": {\"type\": \"string\"}, \"b\": {\"type\": \"number\"}}}") (oas-schema (com.inuoe.jzon:parse example-json)) (schema (oascg-core:schema-from-ht oas-schema)) (names nil)) (is (typep schema 'oascg-core:object-schema)) (is (not (oascg-core:schema-nullable schema))) (funcall (oascg-core:schema-iterator schema) (lambda (schema name required) (push name names) (cond ((string= "a" name) (is (identity required)) (is (typep schema 'oascg-core:simple-schema)) (is (eq :string (oascg-core:simple-schema-type schema))) (is (not (oascg-core:simple-schema-format schema))) (is (not (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema)))) ((string= "b" name) (is (typep schema 'oascg-core:simple-schema)) (is (eq :number (oascg-core:simple-schema-type schema))) (is (not (oascg-core:simple-schema-format schema))) (is (not (oascg-core:simple-schema-enum schema))) (is (not (oascg-core:schema-nullable schema))))))) (is (equal '("b" "a") names)))) (test test-ref (let* ((json "{\"$ref\": \"#/components/schemas/a\"}") (ht (com.inuoe.jzon:parse json)) (schema (oascg-core:schema-from-ht ht)) (schema-uri nil) (handle-unresolved (lambda (err) (setf schema-uri (oascg-core:unresolved-schema-uri err)) (invoke-restart 'use-value (make-instance 'oascg-core:object-schema))))) (handler-bind ((oascg-core:unresolved-schema-error handle-unresolved)) (oascg-core:schema-ref-resolve schema)) (is (string= "#/components/schemas/a" schema-uri))))
6,394
Common Lisp
.lisp
121
44.68595
150
0.61799
fmqa/oascg
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
3706b6619f674f19bcaacdc8fa921825ec2cf2612d4a99aff73b495d35c37219
44,392
[ -1 ]
44,393
oascg.asd
fmqa_oascg/oascg.asd
(defsystem "oascg" :pathname "core" :version "0.1.0" :author "" :license "" :components ((:module "src" :components ((:file "main")))) :in-order-to ((test-op (test-op "oascg/tests"))) :description "" :long-description "") (defsystem "oascg/tests" :pathname "core" :depends-on ("oascg" "com.inuoe.jzon" "fiveam") :components ((:module "tests" :components ((:file "main")))) :perform (test-op (o s) (uiop:symbol-call :fiveam :run! (find-symbol* :oascg-core :oascg-core-tests)))) (defsystem "oascg/typescript" :pathname "typescript" :version "0.1.0" :author "" :license "" :depends-on ("oascg" "com.inuoe.jzon") :components ((:module "src" :components ((:file "main")))) :in-order-to ((test-op (test-op "oascg/typescript/tests"))) :description "" :long-description "") (defsystem "oascg/typescript/tests" :pathname "typescript" :version "0.1.0" :depends-on ("oascg" "oascg/typescript" "com.inuoe.jzon" "fiveam") :components ((:module "tests" :components ((:file "main")))) :perform (test-op (o s) (uiop:symbol-call :fiveam :run! (find-symbol* :oascg-typescript :oascg-typescript-tests)))) (defsystem "oascg/web" :pathname "web" :version "0.1.0" :author "" :license "" :depends-on ("hunchentoot" "oascg" "oascg/typescript" "com.inuoe.jzon") :components ((:module "src" :components ((:file "main")))) :description "" :long-description "")
1,484
Common Lisp
.asd
42
30.761905
99
0.627955
fmqa/oascg
0
0
0
GPL-3.0
9/19/2024, 11:51:56 AM (Europe/Amsterdam)
624debd1eb0dc06e947ab027bb0ce5f6a6d9daa9ff5d8e6b353fd079c686a01a
44,393
[ -1 ]
44,412
package.lisp
Neshamon_graphics-practice/package.lisp
(defpackage #:org.my.project (:use #:cl+trial) (:shadow #:main #:launch) (:local-nicknames (#:v #:org.shirakumo.verbose)) (:export #:main #:launch))
159
Common Lisp
.lisp
6
23.833333
33
0.636364
Neshamon/graphics-practice
0
0
0
GPL-3.0
9/19/2024, 11:52:04 AM (Europe/Amsterdam)
15a5972206530103ba3dd3ccbb149bfc6ee4e644cfb099d318c2099450e6aab4
44,412
[ -1 ]
44,413
keymap.lisp
Neshamon_graphics-practice/keymap.lisp
(in-package #:org.my.project) (ql:quickload '(:trial :trial-glfw :trial-png)) (defclass main (trial:main) ()) (defun launch (&rest args) (apply #'trial:launch 'main args)) (define-asset (trial cat) image #p"cat.png") (define-shader-entity my-cube (vertex-entity textured-entity transformed-entity listener) ((vertex-array :initform (// 'trial 'unit-cube)) (texture :initform (// 'trial 'cat)))) (define-handler (my-cube tick) (tt) (setf (orientation my-cube) (qfrom-angle +vy+ tt))) (defmethod setup-scene ((main main) scene) (enter (make-instance 'my-cube) scene) (enter (make-instance '3d-camera :location (vec 0 0 -3)) scene) (enter (make-instance 'render-pass) scene)) (maybe-reload-scene) (org.my.project:launch)
839
Common Lisp
.lisp
22
31.636364
65
0.629172
Neshamon/graphics-practice
0
0
0
GPL-3.0
9/19/2024, 11:52:04 AM (Europe/Amsterdam)
c14c88d8f8dbf6b3da60e2ad5339b2afffdf0112b74fc5b9e250b32a57d7ed5b
44,413
[ -1 ]
44,414
main.lisp
Neshamon_graphics-practice/main.lisp
(in-package #:org.my.project) (ql:quickload '(:trial :trial-glfw :trial-png)) (defclass main (trial:main) ()) (setf +app-system+ "my-project") (defun launch (&rest args) (let ((*package* #.*package*)) (load-keymap) (setf (active-p (action-set 'in-game)) T) (apply #'trial:launch 'main args))) (define-asset (trial cat) image #p"cat.png") (define-shader-entity my-cube (vertex-entity textured-entity transformed-entity listener) ((vertex-array :initform (// 'trial 'unit-cube)) (texture :initform (// 'trial 'cat)))) (define-handler (my-cube tick) (tt) (setf (orientation my-cube) (qfrom-angle +vy+ tt)) (let ((movement (directional 'move))))) (defmethod setup-scene ((main main) scene) (enter (make-instance 'my-cube) scene) (enter (make-instance '3d-camera :location (vec 0 0 -3)) scene) (enter (make-instance 'render-pass) scene)) (maybe-reload-scene) (org.my.project:launch)
1,014
Common Lisp
.lisp
27
31.518519
65
0.624744
Neshamon/graphics-practice
0
0
0
GPL-3.0
9/19/2024, 11:52:04 AM (Europe/Amsterdam)
8286f1319f8e5af693619496ce07bdc1e3321a8fbfd57a2f2953324a81dc5e3f
44,414
[ -1 ]
44,415
my-project.asd
Neshamon_graphics-practice/my-project.asd
(asdf:defsystem my-project :components ((:file "package") (:file "main")) :depends-on (:trial :trial-glfw :trial-png))
167
Common Lisp
.asd
6
18.833333
32
0.506173
Neshamon/graphics-practice
0
0
0
GPL-3.0
9/19/2024, 11:52:04 AM (Europe/Amsterdam)
b43fb22c1ec5fb2b3613cdd62ddbe8640d1526d6232c17431450042d9cab8ab9
44,415
[ -1 ]
44,434
tagspec.lisp
alonzo-bazaar_xml-lisp/tagspec.lisp
#| per attributes check possiamo fare qualcosa come - nil-attribute - non-nil-attribute - no-attributes - some-attributes - attribute-among-options ( e creare una funzione helper che si vede lei la rappresentazione interna, boh. Je ne sais pas |# (in-package :tagspec) (defstruct spec name closep newline-before-open newline-after-open newline-after-close attributes-check body-check) (defmacro make-spec-short (name &key closep style) "shorthand for when newlines follow a predictable pattern (to be updated once I start taking the attrbute and body checks seriously)" (append `(make-spec :name ,name :closep ,closep) (case style (section '(:newline-before-open t ; html, head, body, div... :newline-after-open t :newline-after-close t)) (header '(:newline-before-open t ; h1, h2... :newline-after-open nil :newline-after-close t)) (typeface '(:newline-before-open nil ; bold, italic... :newline-after-open nil :newline-after-close nil))))) (defparameter *html-spec* (list (make-spec-short "html" :closep nil :style section) (make-spec-short "head" :closep nil :style section) (make-spec-short "body" :closep nil :style section) (make-spec-short "script" :closep nil :style header) (make-spec-short "link" :closep nil :style header) (make-spec-short "h1" :closep nil :style header) (make-spec-short "h2" :closep nil :style header) (make-spec-short "h3" :closep nil :style header) (make-spec-short "h4" :closep nil :style header) (make-spec-short "ul" :closep nil :style section) (make-spec-short "li" :closep nil :style header) (make-spec-short "div" :closep nil :style section) (make-spec-short "form" :closep nil :style section)))
1,890
Common Lisp
.lisp
48
33.041667
135
0.662295
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
780f46b2e0dfcdace47584ae85e9b3c174167da4683d695fade57bb091af40dc
44,434
[ -1 ]
44,435
xmlprint.lisp
alonzo-bazaar_xml-lisp/xmlprint.lisp
(in-package :xmlprint) (defparameter *xml-out-stream* *standard-output* "e con questa se mai dobbiamo fare rendering a stringa basterà fare (let (*xml-out-stream (make-string-out-stream-qualcosa ...)) (stampa roba a *xml-out-stream*))") (defparameter *xml-line-empty-p* t) (defparameter *xml-indentation* 0) (defparameter *xml-pretty-print* t) (defun indent-by (n) (dotimes (x n) (princ #\Space))) (defun xml-indent () (indent-by *xml-indentation*)) (defun xml-princ (thing) (xml-indent) (setf *xml-line-empty-p* nil) (princ thing *xml-out-stream*)) (defmacro xml-format (&rest body) `(progn (xml-indent) (setf *xml-line-empty-p* nil) (format *xml-out-stream* ,@body))) (defun xml-newline () (if (and *xml-pretty-print* (not *xml-line-empty-p*)) (progn (setf *xml-line-empty-p* t) (terpri *xml-out-stream*)))) (defmacro render-string (&rest body) `(with-output-to-string (*xml-out-stream*) ,@body)) (defmacro render-to-file (filename &rest body) `(with-open-file (*xml-out-stream* ,filename :direction :output :if-exists :supersede) ,@body))
1,176
Common Lisp
.lisp
33
30.606061
167
0.643172
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
166e136197211e83600c4a49d32382125a27c792126792bfb9662744a0c100b7
44,435
[ -1 ]
44,436
scratchpad.lisp
alonzo-bazaar_xml-lisp/scratchpad.lisp
(in-package :cl-user) (defmacro paragraph (name) `(xmltags:deftag ,name :closep nil :newline-after-open t :newline-before-close t :newline-after-close t)) (defmacro title (name) `(oneline ,name)) (defmacro oneline (name) `(xmltags:deftag ,name :closep nil :newline-after-open nil :newline-before-close nil :newline-after-close t)) (defmacro facetag (name) `(xmltags:deftag ,name :closep nil :newline-after-open nil :newline-before-close nil :newline-after-close nil)) (paragraph html) (paragraph head) (paragraph body) (paragraph p) (paragraph ul) (paragraph div) (title h1) (title h2) (title h3) (title h4) (title h4) (oneline li) (oneline script) (oneline link) (oneline meta) (oneline title) ;; ros launch files (paragraph launch) (paragraph node) (xmltags:deftag param :closep t :newline-after-close t) (defun ref (key env &key (test #'string=)) "rendering contexts might have to be defined in some more efficient manner later" (cdr (assoc key env :test test))) (defun template (&key env template-body) (html (head (meta :charset (or (ref "charset" env) "utf-8")) (title (or (ref "title" env) "titolo di default"))) (body (cond ((functionp template-body) (funcall template-body)) (t template-body))))) #| note per poi fille mi and company dovrebbero trovarsi in un env la cosa dell'(if functionp else) si potrebbe fare nel ref poi devo capire come "astrarre" il fatto che nell'utilizzo come dati probabile le renderizzo a stringhe altrimenti potrebbe boh faccio che tutte le "liste" o letterali composti vengono interpretati come lambda? non vorrei dover specificare esplicitamente "questo lo renderizzi a stringa qui" non sembra un'ottima cosa, almeno non per l'"astrazione" potrei fare che "è esplicito" che stia chiamando una funzione o meno, e che la funzione poi potrebbe anche renerizzare qualcosa, je ne sais pas l'idea sarebbe mettere questa cosa fino al punto in cui posso buttarla malamaente sul branch di big-rewrite e amen quindi un po' di sforzi sulla feature parity con il frankenstein di prima, che dovrebbero già esserci (salvo with-tag, copialo, boh) o anche prima, rinomina qualche pacchetto a qualcosa di normale, vedi che gira tutto, bellino bellino, sparalo su github, buttalo in qualche chat, chiedi come cazzo è, e prega vedi di fare un readme per questa roba poi, e licenza gplv2, perchè non so la gplv3 che cambia, dovrei leggerla, magari agpl per rompere il cazzo a qualcuno |#
2,519
Common Lisp
.lisp
67
34.940299
175
0.755337
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
865aa30fac1c51bb4ba9a52a7bd157dc257f88cb5695964562fb315fdd2aabf1
44,436
[ -1 ]
44,438
tagenvs.lisp
alonzo-bazaar_xml-lisp/tagenvs.lisp
(in-package :tagenvs) (defun downsym (sym) (string-downcase (symbol-name sym))) ;; for global tag definitions (defmacro deftag (name &optional (closep nil) (newline-before-open nil) (newline-after-open nil) (newline-after-close nil)) `(defmacro ,name (&rest body) (list 'with-tag ,(downsym name) body ,closep ,newline-before-open ,newline-after-open ,newline-after-close))) ;; for local tag definitions ;; (to be replaced with a function generating a tag macrolet from a tag spec struct ;; because I didn't make those tag specs for nothing) (defun lettag (tagsym &rest body) `(,tagsym (&rest body) (list 'with-tag ,(downsym tagsym) body ,@body))) (defmacro with-html (&rest body) `(macrolet ( ,(lettag 'html nil t t t) ,(lettag 'head nil t t t) ,(lettag 'body nil t t t) ,(lettag 'meta nil t nil t) ,(lettag 'title nil t nil t) ,(lettag 'script nil t nil t) ,(lettag 'div nil t t t) ,(lettag 'h1 nil t nil t) ,(lettag 'h2 nil t nil t) ,(lettag 'h3 nil t nil t) ,(lettag 'h4 nil t nil t) ,(lettag 'p nil nil nil t) ,(lettag 'a nil nil nil nil) ,(lettag 'img t nil nil nil) ,(lettag 'ul nil t t t) ,(lettag 'li nil t nil t) ) ,@body))
1,400
Common Lisp
.lisp
39
28.051282
83
0.57735
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
9cca755a1a2adeb57ff392a759f5f850d26dec058a8382a927da03ca663671c1
44,438
[ -1 ]
44,439
xmltags.lisp
alonzo-bazaar_xml-lisp/xmltags.lisp
;;; questi poi andrò a metterli in altri package ;;; schema definition (an html schema, an svg schema, a dae schema, I dunno) #| lo schema includerà i tipi di tag, a ogni tag saranno associati flag quali : - sono aperti o meno - direttive di "pretty printing" (dove mettere i newline quando le stampi, opzionale, di default non mette nessun newline) - TODO : check su che argomenti può avere / non avere - TODO : check su che tipi di sottotag può avere / non avere - TODO : fai che se il body è vuoto viene renderizzata come una tag vuota fattibile anche con un (if (null children) (setf closep t)) tra il multiple-value-bind e il progn |# (in-package :xmltags) (defun should-print-p (elt) "we'd like to be able to write things like (ul (li \"hello\") (li \"world\")) in the templates, to keep the template synthax short, though, to allow this we must have a way to make the program decide \"should I print this or just evaluate it?\", ergo this function" (or (stringp elt) (numberp elt) (characterp elt))) ;; this one thing ;; this gigantic, lovecraftian, thing ;; t'is the beating hearth of this whole library ;; of this whole program ;; of this whole paradigm of "just execute the xml" (defmacro with-tag (tagstr body &optional (closep nil) (newline-before-open nil) (newline-after-open nil) (newline-after-close nil)) ;; parameterize the tag printing code (this is, I'm aware, rather awful) (let ((opening-open-sequence `(progn (when ,newline-before-open (xml-newline)) (xml-princ ,(format nil "<~A" tagstr)))) (opening-close-sequence `(progn (xml-princ ">") (when ,newline-after-open (xml-newline)))) (closing-sequence `(progn (xml-princ ,(format nil "</~A>" tagstr)) (when ,newline-after-close (xml-newline))))) (multiple-value-bind (attributes children) (split-kwargs body) (when closep (assert (null children))) `(progn ,opening-open-sequence ;; attributes, passed as an alist (when ',attributes (xml-princ " ")) ,@(mapcar (lambda (attr-pair) `(let ((key ,(car attr-pair)) (val ,(cdr attr-pair))) (xml-format "~A = \"~A\"" key val))) attributes) ,opening-close-sequence ;; body ,@(mapcar (lambda (child) `(let ((sub ,child)) (when (should-print-p sub) (xml-princ sub)))) children) ,closing-sequence))))
2,690
Common Lisp
.lisp
54
39.944444
267
0.602286
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
3f71a78797b3e6ac1c2234144c25aa874b4be08586641db3c8d6614292f04852
44,439
[ -1 ]
44,440
keyparse.lisp
alonzo-bazaar_xml-lisp/keyparse.lisp
;;; tagbdy parsing #| that is, separating attributes (represented as &key args). we'd like the tag children to be given in a &body argument for syntactic convenience we'd also like to give tag attributes with a kwarg synthax, as it feels more natural this works rather horrendously with cltl2 argument parsing, so guess what, we're making our own, because this is lisp, and we can |# (in-package :keyparse) (defun maybe-first-kwarg (lst) "extracts (cons key val) it that's possible, returns nil otherwise" (and (keywordp (car lst)) (consp (cdr lst)) ; has at least two elements (and proper list, no dots) (cons (string-downcase (symbol-name (car lst))) ; key (cadr lst)))) ; val (defun split-kwargs (body) "returns (values <kwargs> <body>) from a list (append <kwargs> <body>), kwargs are returned as an alist of (cons key val), where key and string are lists, all keys are lowercase, because caps locked html scares me and symbols are case insensitive" (let ((kwargs nil)) (do ((lst body (cddr lst))) (()) (let ((kwarg (maybe-first-kwarg lst))) (if kwarg (push kwarg kwargs) (return-from split-kwargs (values (nreverse kwargs) lst))))))); lst qui prima sine
1,213
Common Lisp
.lisp
24
47.291667
249
0.713322
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
521f657222262408bd7ba57b5ddaa67bc7910e95b78c008f2ae748c53e887919
44,440
[ -1 ]
44,441
packages.lisp
alonzo-bazaar_xml-lisp/packages.lisp
(defpackage :keyparse (:use :cl :cl-user) (:export split-kwargs)) (defpackage :tagspec (:use :cl :cl-user) (:export spec ;; cazzo bello esportare una struct spec-name spec-closep spec-newline-after-open spec-newline-before-close spec-newline-after-close spec-attributes-check spec-body-check *html-spec*)) (defpackage :xmlprint (:use :cl :cl-user) (:export *xml-out-stream* xml-princ xml-format xml-newline)) (defpackage :xmltags (:use :cl :cl-user) (:import-from :keyparse split-kwargs) (:import-from :xmlprint xml-princ xml-format xml-newline) (:export with-tag)) (defpackage :tagenvs (:use :cl :cl-user) (:import-from :xmltags with-tag) (:import-from :xmlprint render-string render-to-file) (:export deftag with-html))
775
Common Lisp
.lisp
25
27.88
77
0.7214
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
7bba394fef7b967f66ed4f3cf6018e1f826e94c05c8d4f60e026e9d9a384a527
44,441
[ -1 ]
44,442
xmltags.asd
alonzo-bazaar_xml-lisp/xmltags.asd
(defsystem :xmltags :description "write html with as much lisp as possible" :version "0.0.2" :author "Alonzo Bazaar <[email protected]>" :components ((:file "packages") (:file "keyparse" :depends-on ("packages")) (:file "tagspec" :depends-on ("packages")) (:file "xmlprint" :depends-on ("packages")) (:file "xmltags" :depends-on ("packages" "xmlprint" "keyparse")) (:file "tagenvs" :depends-on ("packages" "xmltags")) ))
534
Common Lisp
.asd
11
38.636364
79
0.57935
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
9e1b0708be946b76eaa676d27c957e6a08f5354d9a6c94634b6733a332ca0b5b
44,442
[ -1 ]
44,444
titolo.html
alonzo-bazaar_xml-lisp/titolo.html
<html> <head> <title>un blog stupido</title> </head> <body> <h1>default title</h1> <p>default paragraph</p> </body> </html>
124
Common Lisp
.l
9
12.777778
30
0.704348
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
341fb2fb327ae688ac25ba9d7a077f5a60c222dd82a454b1bd7b52a11cedad20
44,444
[ -1 ]
44,447
corpus.html
alonzo-bazaar_xml-lisp/corpus.html
<html> <head> <title>default title</title> </head> <body> <h1>titolo di blog stupido</h1> <p>mi sono alzato stamani, non ho gradito molto la cosa, ma cosa vogliamo farci, mi sono alzato, poi ho pisciato e mi sono fatto un caffe'</p> </body> </html>
249
Common Lisp
.l
9
26.666667
142
0.733333
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
988b2126972169bfe5d4de0412754f0f5d919d4ce4d9aeedf3a677e82f003996
44,447
[ -1 ]
44,455
the-power.html
alonzo-bazaar_xml-lisp/the-power.html
<html> <head> <title>un titolo interessante</title> </head> <body> <h1>una mattina</h1> <h2>mi sono alzato</h2> <h3>o bella ciao</h3> <ul> <li>bella ciao</li> <li>bella ciao, ciao, ciao</li> </ul> </body> </html>
213
Common Lisp
.l
14
14.214286
37
0.683417
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
8370bc7d556802531e83be5573c23a69bc7cb825bf09c96feb29dd37d4a1c1e6
44,455
[ -1 ]
44,456
default.html
alonzo-bazaar_xml-lisp/default.html
<html> <head> <title>default title</title> </head> <body> <h1>default title</h1> <p>default paragraph</p> </body> </html>
122
Common Lisp
.l
9
12.555556
28
0.707965
alonzo-bazaar/xml-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
fd0b9513ccd26f6807b00d2423d1b3582208cf3ae3fcbd284439e242d69c4871
44,456
[ -1 ]
44,471
example.lisp
alonzo-bazaar_xml-lisp-examples/blog-post/example.lisp
(in-package :tagenvs) (defparameter *year-articles-alist* nil) (defparameter *year-month-articles-alist* nil) (defparameter *tag-articles-alist* nil) (defparameter *blog-root-absolute-path* (let ((blog-root-relative-path (make-pathname :directory '(:relative "blog")))) (merge-pathnames blog-root-relative-path))) ;; this does not work on windows boxes ;; TODO: make some (file-uri-to-path) function to address this ;; or whatever abstraction you can come up with at the moment ;; defstruct uri? (defun blog-root-url (&key type) (let ((local-root-url (let ((blog-root-absolute-path-string (princ-to-string *blog-root-absolute-path*))) (format nil "file://~A" blog-root-absolute-path-string))) (remote-root-url "https://alozno-bazaar.github.io/xml-examples/blog-post/blog/")) (case type (remote remote-root-url) (local local-root-url)))) ;; type 'local to run on your machine ;; type 'remote for deployment (here deployed on github pages) (defparameter *blog-root-url* (blog-root-url :type 'local)) (defparameter month-names (make-array 12 :initial-contents '("jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct" "nov" "dec"))) (defstruct date year month day) (defun mkdat (a b c) (make-date :year a :month b :day c)) ;; optimal? no ;; useful? HELL YEAH (defun cat2 (s1 s2) (format nil "~A~A" s1 s2)) (defun catn (&rest ss) (reduce #'cat2 ss :initial-value "")) (defun add-to-year-archive (date path) (let ((year-entry (assoc (date-year date) *year-articles-alist*))) (if year-entry (push path (cdr year-entry)) (push (list (date-year date) path) *year-articles-alist*)))) (defun add-to-year-month-archive (date path) (let ((year (date-year date)) (month (date-month date)) (year-entry (assoc (date-year date) *year-month-articles-alist*))) (unless year-entry (push (list year) *year-month-articles-alist*) (setf year-entry (car *year-month-articles-alist*))) (let ((month-entry (assoc month (cdr year-entry)))) ; :test #'string-equal))) (unless month-entry (push (list month) (cdr year-entry)) (setf month-entry (cadr year-entry))) (push path (cdr month-entry))))) (defun add-to-tag-page (tag path) (let ((tag-entry (assoc tag *tag-articles-alist* :test #'string=))) (if tag-entry (push path (cdr tag-entry)) (push (list tag path) *tag-articles-alist*)))) (defun link-to-tag (tag) (format nil "~Atags/~A.html" *blog-root-url* tag)) (defun link-to-year (year) (format nil "~Aposts/~A/all-year.html" *blog-root-url* year)) (defun link-to-month (&key year month) (format nil "~Aposts/~A/~A/all-month.html" *blog-root-url* year (month-name month))) (defun link-to-blog (&key year month title) (format nil "~Aposts/~A/~A/~A.html" *blog-root-url* year (month-name month) title)) (defun month-name (number) (svref month-names (1- number))) (with-html (defun render-blog-post (filepath &key title author date tags body) (render-to-file filepath (html (head (meta :charset "utf8" :lang "en") (title "some blog post")) (body (h1 :class "blog-title" title) (div :class "below-the-title" :style "text-align:right" (h3 "author : " author) (h3 "date : " (format nil "~A/~A/~A" (date-year date) (date-month date) (date-day date)))) (div :class "blog-main-body" body) (div :class "blog-tags" (ul (dolist (tag tags) (li (a :href (link-to-tag tag) tag))))))))) ;; and finally (defun add-blog-post (&key (title "defalt.html") (date (make-date :year 1970 :month 1 :day 1)) (author "default author") (tags nil) (body nil)) (let* ((blog-file-directory (blog-directory-path date)) (blog-file-path (file-in-directory title blog-file-directory))) (ensure-directories-exist blog-file-directory) (add-to-year-archive date blog-file-path) (add-to-year-month-archive date blog-file-path) (dolist (tag tags) (add-to-tag-page tag blog-file-path)) (render-blog-post (princ-to-string blog-file-path) :title title :author author :date date :tags tags :body body))) (defun test-run () (add-blog-post :title "mamma.html" :author "mia" :date (mkdat 2001 9 11) :tags '("very" "sad") :body (render-string (h1 "ok") (h2 "not ok") (div :class "flex" (h4 "whoami") (p "root")))) (add-blog-post :title "kite.html" :author "mmuort" :date (mkdat 2000 10 10) :tags '("tarantella" "ultras") :body (render-string (h1 "forza napoli") (ul (dolist (x '("na bandiera tutta azzura" "ca rassomiglia cielo" "è un mare sta città" "forza Napoli")) (li :class "box" x)) (li :class "bot" (a :href "goatse.cx" "dat ass"))))) (add-blog-post :tags '("ei" "fu" "tarantella") :body "siccome immobile")) (defun render-archives () (render-index) (render-tag-pages) (render-year-archives) (render-year-month-archives) ) (defun render-index () nil) ;; some dry got wet with these (defun render-tag-pages () (ensure-directories-exist (format nil "~Atags/" *blog-root-absolute-path*)) (dolist (ta *tag-articles-alist*) (let ((tag (car ta)) (posts (cdr ta))) (render-to-file (format nil "~Atags/~A.html" *blog-root-absolute-path* tag) (base-archive :title (format nil "blogs tagged ~A" tag) :lst (mapcar #'princ-to-string posts)))))) (defun render-year-archives () (ensure-directories-exist (format nil "~Aposts/" *blog-root-absolute-path*)) (dolist (ye *year-articles-alist*) (let ((year (car ye)) (posts (cdr ye))) (ensure-directories-exist (format nil "~Aposts/~A/" *blog-root-absolute-path* year)) (render-to-file (format nil "~Aposts/~A/all-year.html" *blog-root-absolute-path* year) (base-archive :title (format nil "blogs in year ~A" year) :lst (mapcar #'princ-to-string posts)))))) ;; this function looks BAD ;; REALLY BAD ;; probably syntomatic of a very lassiez lister attitude towards the usage of data structures within the code at hand (defun render-year-month-archives () (ensure-directories-exist (cat2 *blog-root-absolute-path* "posts/")) (dolist (yemo *year-month-articles-alist*) (let ((year (car yemo)) (months (cdr yemo))) (dolist (m months) (let ((month (car m)) (posts (cdr m))) (let ((month-dir (catn *blog-root-absolute-path* "posts/" year "/" (month-name month) "/"))) (ensure-directories-exist month-dir) (render-to-file (cat2 month-dir "all-month.html") (base-archive :title (catn "posts in month " (month-name month) " of year " year) :lst (mapcar #'princ-to-string posts))))))))) (defun base-archive (&key title lst) (html (head (meta :charset "utf8") (title title)) (body (h1 :class "archive-head" title) (ul :class "archive-list" (dolist (l lst) (li l)))))) ) ;; blogs are already rendered, so render the archive and tag pages (defun blog-directory-path (date) (merge-pathnames (make-pathname :directory `(:relative "posts" ,(princ-to-string (date-year date)) ,(month-name (date-month date)))) *blog-root-absolute-path*)) (defun file-in-directory (filename blog-file-directory) (multiple-value-bind (name type) (split-last-dot filename) (merge-pathnames blog-file-directory (if type (make-pathname :name name :type type) (make-pathname :name name))))) (defun split-last-dot (str) (let ((lastdot (position #\. str :from-end t))) (if lastdot (values (subseq str 0 lastdot) (subseq str (1+ lastdot))) (values str nil)))) (defun make-blog-directory (date title) (when (or date title) nil))
9,676
Common Lisp
.lisp
198
34.621212
135
0.525747
alonzo-bazaar/xml-lisp-examples
0
0
0
GPL-2.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
8e28837af1ac0089b781087fce4a0b20ef3cb2b2876e656d16c6dbbc5cec2c18
44,471
[ -1 ]
44,472
ussage.asd
alonzo-bazaar_xml-lisp-examples/blog-post/ussage.asd
#| this system is one file the whole point of this defsystem is making asdf load the xmltags package before loading the example usage file |# (defsystem :ussage ;; mispelling is intentional :author "somebody that you used to know" :license "GPLv2" :version "0" :depends-on ("xmltags") :components ((:file "example")))
328
Common Lisp
.asd
10
30.8
111
0.748428
alonzo-bazaar/xml-lisp-examples
0
0
0
GPL-2.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
a5663366a8919d752280475ef02851fa5ab3699b1279f331738c1fc5f3b1f705
44,472
[ -1 ]
44,475
kitemmurt.html
alonzo-bazaar_xml-lisp-examples/blog-post/kitemmurt.html
<html> <head> <meta charset = "utf8"></meta> <title>cristo</title> </head> <body> <h1 class = "archive-head">cristo</h1> <ul class = "archive-list"> <li>ma</li> <li>che</li> <li>bella</li> <li>giovinezza</li> </ul> </body> </html>
231
Common Lisp
.l
15
14.4
38
0.652778
alonzo-bazaar/xml-lisp-examples
0
0
0
GPL-2.0
9/19/2024, 11:52:12 AM (Europe/Amsterdam)
1be0ff240f21d273adca0c21f5a9e65bd395a3d4cbc39bc16993bb9e41088056
44,475
[ -1 ]
44,490
program_to_run.lisp
Volko76_Lisp-To-HTML/program_to_run.lisp
; THIS IS THE PROGRAM TO RUN (setq page '(html (header (title Marin Le BG du 64) ) (body (h1 Magnifique Homme) (p Vaut 65 e chez amazon) ) ) ) (defun make-html(L) (dolist (element L) (if (atom element) (progn (if (not(equal (car L) element)) (progn (write element) (write-char #\space)) (progn (write-string "<") (write element) (write-string ">") ) ) ) (make-html element)) ) (write '</) (write (car L)) (write '>) T) (make-html page)
812
Common Lisp
.lisp
33
12.212121
48
0.37037
Volko76/Lisp-To-HTML
0
0
0
GPL-3.0
9/19/2024, 11:52:21 AM (Europe/Amsterdam)
2c98b7898dcd5e8d33eb24c97f0f9be1ea1e916f187e7da0fe655b3e55355500
44,490
[ -1 ]
44,507
tokenize-test.lisp
alexrudnick_nlp-sketches-lisp/tokenize-test.lisp
(load "~/quicklisp/setup.lisp") ;; is there a cleaner way to include this? (load "tokenize.lisp") (ql:quickload "1am") (defpackage :tokenize-test (:use :cl :1am :tokenize)) (in-package :tokenize-test) (defconstant *properly-split* (list "this" "ought" "to" "return" "a" "list" "of" "words")) (test split-by-spaces-test (is (equalp *properly-split* (tokenize::split-by-spaces "this ought to return a list of words"))) (is (equalp *properly-split* (tokenize::split-by-spaces "this ought to return a list of words"))) (is (equalp *properly-split* (tokenize::split-by-spaces "this ought to return a list of words "))) (is (equalp *properly-split* (tokenize::split-by-spaces " this ought to return a list of words ")))) (run)
873
Common Lisp
.lisp
22
32.454545
65
0.600711
alexrudnick/nlp-sketches-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
6128b0aac7017ff3823c155a156955e9a7a3c516f6e9611a55a694d75b6e80e0
44,507
[ -1 ]
44,508
toktok-demo.lisp
alexrudnick_nlp-sketches-lisp/toktok-demo.lisp
(load "~/quicklisp/setup.lisp") ;; is there a cleaner way to include this? (load "tokenize.lisp") (defpackage :tokenize-demo (:use :cl :tokenize)) (in-package :tokenize-demo) (loop for line = (read-line *standard-input* nil nil) while line do (progn (tokenize::print-word-list (tokenize::toktok-tokenize line))))
339
Common Lisp
.lisp
9
33.777778
73
0.691131
alexrudnick/nlp-sketches-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
65fdd2882c2e2c6360a786a5f4ea2a68689e95110a55e8dcb28f408f6942343d
44,508
[ -1 ]
44,509
tokenize.lisp
alexrudnick_nlp-sketches-lisp/tokenize.lisp
;; Say we wanted to write a nice tokenizer in Common Lisp. ;; The real goal will be to do something at least as nice as the Punkt ;; tokenizer in NLTK, and also the sent_tokenize function. ;; open question: What's the situation with Unicode in Common Lisp? (load "~/quicklisp/setup.lisp") (ql:quickload "cl-ppcre") (asdf:oos 'asdf:load-op :cl-ppcre-unicode) (defpackage :tokenize (:use :cl :cl-ppcre)) (in-package :tokenize) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; split-by-spaces: simplest tokenization situation. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun split-by-spaces (text) (mapcar (lambda (backwards-letters) (coerce (nreverse backwards-letters) 'string)) (split-by-spaces-list '() (coerce text 'list)))) (defun split-by-spaces-list (cur-word characters-left) ;; this ought to return a list of strings. (cond ((null characters-left) (if cur-word (list cur-word) '())) ((whitespacep (car characters-left)) (if cur-word (cons cur-word (split-by-spaces-list '() (cdr characters-left))) (split-by-spaces-list '() (cdr characters-left)))) (t (split-by-spaces-list (cons (car characters-left) cur-word) (cdr characters-left))))) ;; XXX: we could have a more expansive version of whitespace detection, and ;; there may be a good predicate for this in the standard library. (defun whitespacep (c) (cond ((equalp #\Space c) t) ((equalp #\Newline c) t) (t nil))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; toktok from NLTK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; this is going to use the regex-replace-all function in cl-ppcre (defun toktok-tokenize (text) (split-by-spaces (apply-every-regex *toktok-regex-pairs* text))) (defun apply-every-regex (regex-pairs text) (cond ((null regex-pairs) text) (t (let ((regex (caar regex-pairs)) (replacement (cdar regex-pairs))) (apply-every-regex (cdr regex-pairs) (regex-replace-all regex text replacement)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; misc utilities ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun print-word-list (words) (progn (format t "here's you some words...~%") (loop for word in words do (format t "word: [~a] ~%" word)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; toktok patterns ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (load "toktok-patterns.lisp")
2,792
Common Lisp
.lisp
64
39.4375
80
0.505353
alexrudnick/nlp-sketches-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
0ccda362a91d0f56c89af6d9df7a0b8d99c7df6a8edc5f6cbb8736ac56116ddf
44,509
[ -1 ]
44,510
toktok-test.lisp
alexrudnick_nlp-sketches-lisp/toktok-test.lisp
(load "~/quicklisp/setup.lisp") ;; is there a cleaner way to include this? (load "tokenize.lisp") (ql:quickload "1am") (defpackage :tokenize-test (:use :cl :1am :tokenize)) (in-package :tokenize-test) (defconstant *dr-bob-joined* "They thought, \"Is 9.5 or 525,600 my favorite number?\" before seeing Dr. Bob's dog talk.") (defconstant *dr-bob-correct* (tokenize::split-by-spaces "They thought , \" Is 9.5 or 525,600 my favorite number ? \" before seeing Dr. Bob ' s dog talk .")) ;; XXX: add a test to show that we handle ] correctly. (test dr-bob-test (is (equalp *dr-bob-correct* (tokenize::toktok-tokenize *dr-bob-joined*)))) ;; >>> toktok = ToktokTokenizer() ;; >>> text = u'Is 9.5 or 525,600 my favorite number?' ;; >>> print(toktok.tokenize(text, return_str=True)) ;; Is 9.5 or 525,600 my favorite number ? ;; >>> text = u'The https://github.com/jonsafari/tok-tok/blob/master/tok-tok.pl is a website with/and/or slashes and sort of weird : things' ;; >>> print(toktok.tokenize(text, return_str=True)) ;; The https://github.com/jonsafari/tok-tok/blob/master/tok-tok.pl is a website with/and/or slashes and sort of weird : things ;; >>> text = u'\xa1This, is a sentence with weird\xbb symbols\u2026 appearing everywhere\xbf' ;; >>> expected = u'\xa1 This , is a sentence with weird \xbb symbols \u2026 appearing everywhere \xbf' ;; >>> assert toktok.tokenize(text, return_str=True) == expected ;; >>> toktok.tokenize(text) == [u'\xa1', u'This', u',', u'is', u'a', u'sentence', u'with', u'weird', u'\xbb', u'symbols', u'\u2026', u'appearing', u'everywhere', u'\xbf'] ;; True ;; Don't tokenize period unless it ends the line and that it isn't ;; preceded by another period, e.g. ;; "something ..." -> "something ..." (test eol-periods-test (is (equalp (tokenize::split-by-spaces "something ...") (tokenize::toktok-tokenize "something ...")))) ;; "something." -> "something ." (test eol-single-period-test (is (equalp (tokenize::split-by-spaces "something .") (tokenize::toktok-tokenize "something.")))) ;; Don't tokenize period unless it ends the line eg. ;; " ... stuff." -> "... stuff ." (test beginning-periods-test (is (equalp (tokenize::split-by-spaces "... stuff .") (tokenize::toktok-tokenize "... stuff.")))) (test internal-ellipsis-test (is (equalp (tokenize::split-by-spaces "also more ... stuff .") (tokenize::toktok-tokenize "also more ... stuff.")))) ;; Demonstrate that the "FUNKY_PUNCT_1" and "FUNKY_PUNCT_2" patterns do what ;; they're supposed to do. For example, FUNKY_PUNCT_1 splits out inverted question ;; marks. (test funky-punct-1-test (is (equalp (tokenize::split-by-spaces "¿ Quieres una taza de café ?") (tokenize::toktok-tokenize "¿Quieres una taza de café?")))) ;; This one would have failed without the FUNKY_PUNCT_2 pattern included. (test funky-punct-2-test (is (equalp (tokenize::split-by-spaces "« Sí , por favor . »") (tokenize::toktok-tokenize "«Sí, por favor.»")))) (run)
3,110
Common Lisp
.lisp
56
51.785714
174
0.658504
alexrudnick/nlp-sketches-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
982249ea3b6ece2a831936c15293bacf06d847906aa68e2f8f7909941bc6c247
44,510
[ -1 ]
44,511
toktok-patterns.lisp
alexrudnick_nlp-sketches-lisp/toktok-patterns.lisp
(defconstant *ampercent* '("& " . "&amp; ")) (defconstant *close-punct-re* '("([\\p{Close_Punctuation}])" . "\\1 ")) (defconstant *comma-in-num* '("(?<!,)([,،])(?![,\\d])" . " \\1 ")) (defconstant *currency-sym-re* '("([\\p{Currency_Symbols}])" . "\\1 ")) (defconstant *en-em-dashes* '("([–—])" . " \\1 ")) (defconstant *final-period-1* '("(?<![.])[.]$" . " .")) (defconstant *final-period-2* '("(?<![.])[.]\s*([\"'’»›”]) *$" . " . \\1")) ;; XXX: took \] out of this one from the Python code, but that should be covered ;; by Close_Punctuation. There's a test to show that this is covered. (defconstant *funky-punct-1* '("([،\;؛¿!\")}»›”؟¡%٪°±©®।॥…])" . " \\1 ")) (defconstant *funky-punct-2* '("([({\[“‘„‚«‹「『])" . " \\1 ")) (defconstant *multi-commas* '("(,{2,})" . " \\1 ")) (defconstant *multi-dashes* '("(-{2,})" . " \\1 ")) (defconstant *multi-dots* '("([.]{2,})" . " \\1 ")) (defconstant *non-breaking* '(" " . " ")) (defconstant *one-space* '(" {2,}" . " ")) (defconstant *open-punct-re* '("([\\p{Open_Punctuation}])" . "\\1 ")) (defconstant *pipe* '("[|]" . " &#124; ")) (defconstant *prob-single-quotes* '("(['’`])" . " \\1 ")) (defconstant *stupid-quotes-1* '(" ` ` " . " `` ")) (defconstant *stupid-quotes-2* '(" ' ' " . " '' ")) (defconstant *tab* '(" " . " &#9; ")) (defconstant *url-foe-1* '(":(?!//)" . " : ")) (defconstant *url-foe-2* '("\\?(?!\S)" . " ? ")) (defconstant *url-foe-3* '("(:\/\/)[\S+[.]\S+\/\S+][\/]" . " / ")) (defconstant *url-foe-4* '(" /" . " / ")) (defconstant *toktok-regex-pairs* (list *non-breaking* ;; XXX: this is a messy hack and I think it means there's something ;; wrong with final-period-2 or perhaps funky-punct-2. *final-period-2* *funky-punct-1* *funky-punct-2* *url-foe-1* *url-foe-2* *url-foe-3* *url-foe-4* *ampercent* *tab* *pipe* *open-punct-re* *close-punct-re* *multi-commas* *comma-in-num* *prob-single-quotes* *stupid-quotes-1* *stupid-quotes-2* *currency-sym-re* *en-em-dashes* *multi-dashes* *multi-dots* *final-period-1* *final-period-2* *one-space* ))
2,484
Common Lisp
.lisp
104
18.375
80
0.460738
alexrudnick/nlp-sketches-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
6e8d4ae35e9b86e654d209ba2edf3c771a444719197e5f613229d48474540ddb
44,511
[ -1 ]
44,512
cfg.lisp
alexrudnick_nlp-sketches-lisp/cfg.lisp
;;; This could be improved quite a lot. (defvar *grammar-rules* '((S -> NP VP) (VP -> V NP) (VP -> VP PP) (NP -> NP PP) (NP -> NP NP) (PP -> P NP))) (defvar *pos-rules* '((NP -> "people") (NP -> "fish") (NP -> "tanks") (NP -> "rods") (V -> "people") (V -> "fish") (V -> "tanks") (P -> "with"))) (defvar *pos-rules-2* '((NP -> "binoculars") (NP -> "bob") (NP -> "mary") (NP -> "saw") (V -> "saw") (P -> "with"))) (defvar *grammar-rules-2* '((S -> NP VP) (VP -> V NP) (VP -> VP PP) (PP -> P NP) (NP -> NP PP))) ;; going to return a list of (index postag word) (defun pos-tag (words rules) (pos-tag-help 0 words rules rules)) (defun pos-tag-help (index words rules orig-rules) (cond ((null words) nil) ;; out of rules, on to the next word! ((null rules) (pos-tag-help (+ 1 index) (cdr words) orig-rules orig-rules)) ;; current word matches current rule ((equalp (car words) (caddar rules)) (cons (list index (caar rules) (car words)) (pos-tag-help index words (cdr rules) orig-rules))) ;; current word does not match current rule, try next rule. (t (pos-tag-help index words (cdr rules) orig-rules)))) (defun width-start-split-triples (wordlength) (loop for width from 2 to wordlength append ;; for start in range(0, len(words) + 1 - width): (loop for start from 0 to (- wordlength width) append ;; for split in range(1, width): (loop for split from 1 to (- width 1) collect (list width start split))))) (defun build-chart (word-grammar rule-grammar words) (let ((chart (make-hash-table :test #'equalp))) (progn (let ((tagged (pos-tag words word-grammar))) (loop for entry in tagged do (progn ;; (format t "~a~%" entry) (let ((span (list (car entry) (+ 1 (car entry))))) ;; the entries in the hash table are keyed by (start, end) and ;; they are lists of what's in that span. (setf (gethash span chart) (cons (list (cadr entry) (caddr entry) nil) (gethash span chart))))))) ;; now do production rules ;; for every width 2..whole sentence (loop for triple in (width-start-split-triples (length words)) do (let* ((width (car triple)) (start (cadr triple)) (split (caddr triple)) (span (list start (+ start width)))) ;; for every production... (loop for rule in rule-grammar do (let ((A (caddr rule)) (B (cadddr rule))) (loop for leftcell in (gethash (list start (+ start split)) chart) do (loop for rightcell in (gethash (list (+ start split) (+ start width)) chart) do (if (and (equalp (car leftcell) A) (equalp (car rightcell) B)) (setf (gethash span chart) (cons (list (car rule) leftcell rightcell) (gethash span chart)))))))))) chart))) (defun cky-demo (sentence pos-rules grammar-rules &optional (print-chart nil)) (progn (format t "~%####################################~%") (format t "example: ~a~%" sentence) (let ((parsed (build-chart pos-rules grammar-rules sentence))) (progn (if print-chart (progn (format t "contents of the chart...~%") (loop for key being the hash-key of parsed do (progn (format t "~a~%" key) (format t " ~a~%" (gethash key parsed)))))) (loop for entry in (gethash (list 0 (length sentence)) parsed) do (if (equalp (car entry) 'S) (format t "complete parse: ~a~%" entry))))))) (cky-demo (list "people" "fish" "fish") *pos-rules* *grammar-rules*) (cky-demo (list "mary" "saw" "bob" "with" "binoculars") *pos-rules-2* *grammar-rules-2*) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; WIP; make this much cleaner and lispier. The earlier version is a close ;; transliteration of some Python, and it's pretty gross in Common Lisp. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun parse (words) (let* ((tagged (pos-tag words *pos-rules*))) (parse-help tagged *grammar-rules*))) (defun parse-help (inventory rules) ;; apply rules until we make a pass over the rules and achieve quiescence ;; so if we go over all the rules and nothing new fired, then we're done. ;; at each step, we return the new inventory. (let ((next-inventory (parse-help-one-pass inventory rules))) (cond ((equalp next-inventory inventory) next-inventory) (t (parse-help next-inventory rules))))) (defun parse-help-one-pass (inventory rules) (cond ;; if we're out of rules, we're done. ((null rules) inventory) ;; check to see if we can apply the first rule. if we can, apply it and go ;; to the next rule. ((rule-applies (car rules) (inventory)) (parse-help-one-pass (cons (apply-rule (car rules) inventory) inventory) (cdr rules))) ;; if the first rule doesn't apply, go to the next one. (t (parse-help-one-pass inventory (cdr rules)))))
5,515
Common Lisp
.lisp
132
33.174242
81
0.540303
alexrudnick/nlp-sketches-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
e2c51e838bcf794989fdeb79c378a1496574d3b7ef368ba0d45759110b6143da
44,512
[ -1 ]
44,513
gameoflife.lisp
alexrudnick_nlp-sketches-lisp/other-sketches/gameoflife.lisp
;; Game Of Life in Common Lisp ;; Isak Falk & Alex Rudnick, pair programming! ;; Very slightly cleaned up by Alex Rudnick after the fact. ;; Common Lisp has multidimensional arrays. (defun create-board (size) (make-array (list size size))) (defun create-oscillator-board () (let ((output (create-board 5))) (progn (setf (aref output 1 1) T) (setf (aref output 1 2) T) (setf (aref output 1 3) T) output))) ;; what are the rules exactly? ;; for each cell ;; -- check every neighbor and count how many are truthy ;; -- based on how many are truthy, that gives you the status for next time. ;; we've decided: if you reach off the edge of the board, then that counts as ;; dead. ;; Relative offsets for all the neighbors of a cell. (defconstant neighbors-offsets '( (-1 -1) (-1 0) (-1 1) (0 -1) (0 1) (1 -1) (1 0) (1 1))) (defun check-alive (board i j) (cond ((< i 0) 0) ((< j 0) 0) ((>= i (cadr (array-dimensions board))) 0) ((>= j (car (array-dimensions board))) 0) (t (if (aref board i j) 1 0)))) ;; count-alive-neighbors (defun count-alive-neighbors (board i j) ;; diagonals count as neighbors (loop for offset in neighbors-offsets sum (check-alive board (+ i (car offset)) (+ j (cadr offset))) into total finally (return total))) ;; next-board ;; return a completely fresh board that contains the next state ;; any live cell with 2 or 3 neighbors survives ;; if the cell is false, and it has 3 live neighbors, it becomes alive ;; any other cell becomes false. (defun make-indices (boardsize) (loop for i from 0 to (- boardsize 1) append (loop for j from 0 to (- boardsize 1) collect (list i j)))) (defun next-board (board) (let* ((boardsize (car (array-dimensions board))) (output (create-board boardsize)) (indices (make-indices boardsize))) (loop for idx in indices do (let* ((i (car idx)) (j (cadr idx)) (num-alive (count-alive-neighbors board i j)) (is-alive (aref board i j))) (cond ((and is-alive (find num-alive (list 2 3))) (setf (aref output i j) T)) ((and (not is-alive) (= num-alive 3)) (setf (aref output i j) T)) (T (setf (aref output i j) nil))))) output))
2,515
Common Lisp
.lisp
68
29.455882
77
0.579055
alexrudnick/nlp-sketches-lisp
0
0
0
GPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
17c36ee7e2088aee9e13109f903cc0b7ea21822a1ac8ba861aefd511d4a01999
44,513
[ -1 ]
44,536
gstreamer.lisp
bohonghuang_cl-gstreamer/gstreamer.lisp
;;;; gstreamer.lisp ;;;; Copyright (C) 2023 Bohong Huang ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Lesser General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Lesser General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Lesser General Public License ;;;; along with this program. If not, see <https://www.gnu.org/licenses/>. (cl:defpackage gst-check (:use)) (cl:in-package #:gst-check) (gir-wrapper:define-gir-namespace "GstCheck" "1.0") (cl:defpackage gst-controller (:use)) (cl:in-package #:gst-controller) (gir-wrapper:define-gir-namespace "GstController" "1.0") (cl:defpackage gst-net (:use)) (cl:in-package #:gst-net) (gir-wrapper:define-gir-namespace "GstNet" "1.0") (uiop:define-package gstreamer (:use) (:nicknames #:gst) (:use-reexport #:gst-check #:gst-controller #:gst-net)) (cl:in-package #:gst) (gir-wrapper:define-gir-namespace "Gst" "1.0")
1,309
Common Lisp
.lisp
33
37.909091
80
0.726841
bohonghuang/cl-gstreamer
0
0
0
LGPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
56bfe4984232e7ff2580d111befbf39db9c1ba0517459ab03078f5dd77710a70
44,536
[ -1 ]
44,537
cl-gstreamer.asd
bohonghuang_cl-gstreamer/cl-gstreamer.asd
(defsystem cl-gstreamer :version "1.0.0" :author "Bohong Huang <[email protected]>" :maintainer "Bohong Huang <[email protected]>" :license "lgpl3" :description "GStreamer bindings for Common Lisp." :homepage "https://github.com/bohonghuang/cl-gstreamer" :bug-tracker "https://github.com/bohonghuang/cl-gstreamer/issues" :source-control (:git "https://github.com/bohonghuang/cl-gstreamer.git") :serial t :components ((:file "gstreamer")) :depends-on (#:uiop #:cl-gobject-introspection-wrapper)) (uiop:register-image-restore-hook (lambda () (dolist (namespace '("Gst" "GstCheck" "GstController" "GstNet")) (let ((package (find-package (string-upcase namespace)))) (when package (setf (symbol-value (find-symbol "*NS*" package)) (uiop:symbol-call :gir :require-namespace namespace "1.0")))))))
855
Common Lisp
.asd
19
40.684211
79
0.699401
bohonghuang/cl-gstreamer
0
0
0
LGPL-3.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
252ab0a10a055cb92dcc04b7b5805cc7d76e1006da8479647f193e4d598f7fed
44,537
[ -1 ]
44,555
model.lisp
cadrgtsecond_cl-trello/src/model.lisp
(defpackage cl-trello.model (:use :cl :sxql) (:documentation "Structs and functions to pull data from the database") (:export todo get-todos reorder-todos create-todo todo-desc todo-order todo-group group-desc group-id)) (in-package :cl-trello.model) (mito:connect-toplevel :sqlite3 :database-name #p"db.sqlite3") (mito:deftable todo-group () ((id :col-type :integer :primary-key t :initform (fields (select ((:coalesce (:+ 1 (:max :id)) 0)) (from :todo_group)))) (desc :col-type :text)) (:conc-name group-) (:documentation "A group of todos. The id indicates the ordering")) (mito:deftable todo () ((order :col-type :integer) (desc :col-type :text) (done-p :col-type :boolean :initform nil) (group :references todo-group)) (:primary-key order group)) (defmethod initialize-instance :after ((self todo) &key id group) "Ensure id is incrementing and unique" (unless id (setf (todo-order self) (fields (select ((:coalesce (:+ 1 (:max :todo.order)) 0)) (from :todo) (where (:= :group group))))))) #+nil (progn (mito:create-dao 'todo-group :desc "Helpful Info") (mito:create-dao 'todo-group :desc "To Do") (mito:create-dao 'todo-group :desc "In Progress") (mito:create-dao 'todo-group :desc "Ready for Launch")) #+nil (progn (create-todo 0 "What is this?") (create-todo 0 "Target launch date: ") (create-todo 1 "Add some blink") (create-todo 1 "Support custom groups") (create-todo 1 "Setup end to end testing") (create-todo 2 "In Progress") (create-todo 2 "Get it done")) (defun create-todo (group desc) (mito:create-dao 'todo :group group :desc desc)) #+nil (insert-into :todo (set= :group "HI" :desc "Desc" :order (fields (select ((:+ 1 (:max :order))) (from :todo))))) (defun plist->dao (class plist &rest mappings) "Useful function to convert a plist into a mito type. See `get-todos` for an example" (apply #'mito:make-dao-instance class (loop for (key attr) on mappings by #'cddr appending `(,key ,(getf plist attr))))) (defun plist->dao* (class &rest mappings) "`plist->dao` but curried" (lambda (i) (apply #'plist->dao class i mappings))) (defun get-todos () (mapcar (lambda (g) (list* (plist->dao 'todo-group (car g) :id :group :desc :group-desc) (mapcar (plist->dao* 'todo :group :group :order :order :desc :desc) g))) (serapeum:assort (mito:retrieve-by-sql (select ((:as :todo_group.id :group) (:as :todo_group.desc :group-desc) :todo.desc :todo.order :done_p) (from :todo_group) (left-join :todo :on (:= :todo_group.id :todo.group)) (order-by :group :todo.order))) :key (lambda (e) (getf e :group))))) (defun reorder-todos (&key to from neword oldord) "Reorders todos" (dbi:with-transaction mito:*connection* (mito:execute-sql (update 'todo (set= :order (:+ :order 1) :group to) (where (:and (:= :order oldord) (:= :group from)))))))
3,256
Common Lisp
.lisp
91
29.142857
87
0.599683
cadrgtsecond/cl-trello
0
0
0
GPL-2.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
24a4e823fe132c9708f9f168faba5ad31eb070a71b000f9d06c09b33a25b13d2
44,555
[ -1 ]
44,556
main.lisp
cadrgtsecond_cl-trello/src/main.lisp
(defpackage cl-trello (:use :cl :iterate) (:local-nicknames (:model cl-trello.model) (:templates cl-trello.templates) (:a alexandria))) (in-package :cl-trello) (defvar *app* (make-instance 'ningle:app)) ;; Serve css (setf (ningle:route *app* "/css/index.css") (lambda (params) `(200 (:content-type "text/css") (,(defcss:file->string templates:*index.css*))))) (defmacro ok-html (html &key headers) ``(200 ,,headers (,(spinneret:with-html-string ,html)))) (setf (ningle:route *app* "/" :method :GET) (constantly '(301 (:location "/todos") ("")))) (setf (ningle:route *app* "/todos" :method :GET) (lambda (params) (declare (ignore params)) (ok-html (templates:index (model:get-todos))))) (setf (ningle:route *app* "/groups/:group" :method :POST) (lambda (params) (let ((desc (cdr (assoc "desc" params :test #'string=))) (group (parse-integer (cdr (assoc :group params :test #'string=))))) (check-type desc string) (check-type group integer) (a:if-let (todo (model:create-todo group desc)) (ok-html (templates:todo-element todo)) `(500 () ()))))) (setf (ningle:route *app* "/groups/:group" :method :PUT) (lambda (params) (model:reorder-todos ;; A little repetition is okay :to (parse-integer (cdr (assoc "to" params :test #'string=))) :from (parse-integer (cdr (assoc "from" params :test #'string=))) :oldord (parse-integer (cdr (assoc "oldord" params :test #'string=))) :neword (parse-integer (cdr (assoc "neword" params :test #'string=)))) `(204 ()))) (setf (ningle:route *app* "/groups/:group/:order" :method :DELETE) (lambda (params) (let ((group (parse-integer (cdr (assoc :group params)))) (order (parse-integer (cdr (assoc :order params))))) (mito:delete-dao (make-instance 'model:todo :group group :order order))))) (defun start () (clack:clackup (lack:builder (:mito '(:sqlite3 :database-name "db.sqlite3")) :backtrace (:static :path "/vendor/" :root #p"vendor/") (:static :path "/js/" :root #p"js/") *app*) :server :hunchentoot)) #+nil (progn (defvar *handle* nil) (when *handle* (clack:stop *handle*)) (setf *handle* (start)))
2,296
Common Lisp
.lisp
58
34.086207
86
0.612657
cadrgtsecond/cl-trello
0
0
0
GPL-2.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
92fbe142b9b0f40ba58225be4860310034667c74afcbd069b724ed15a2993cd7
44,556
[ -1 ]
44,557
templates.lisp
cadrgtsecond_cl-trello/src/templates.lisp
(defpackage cl-trello.templates (:use :cl :iter :defcss) (:local-nicknames (:a :alexandria) (:model :cl-trello.model)) (:export todo-element index *index.css*)) (in-package cl-trello.templates) (push "hx-" spinneret:*unvalidated-attribute-prefixes*) (push "js-" spinneret:*unvalidated-attribute-prefixes*) (defparameter *index.css* (make-css-file)) (defcss (:root (:global t) (:in *index.css*)) :--text-color (:var --gray-8) :--primary-background (:var --gray-1) :--secondary-background (:var --gray-0) :--primary-color (:var --blue-9)) (defcss (* (:global t) (:in *index.css*)) :box-sizing border-box) (defcss (body (:global t) (:in *index.css*)) :width auto :height 100vh :padding (:var --size-2) :margin 0 :color (:var --text-color) :background (:var --primary-background)) (defcss (nice-button (:in *index.css*)) ;; Reset notrmal styles :border none :background (:var --primary-color) :color (:var --primary-background) :border-radius (:var --radius-2)) (defmacro with-page (head &rest body) `(spinneret:with-html (:doctype) (:html (:head (:meta :name "viewport" :content "width=device-width, initial-scale=1") (:meta :name "charset" :content "UTF-8") (:link :rel "stylesheet" :href "/vendor/openprops.min.css") (:link :rel "stylesheet" :href "/css/index.css") (:script :src "/vendor/htmx.js" "") ,@head) (:body ,@body)))) (defcss (todo-element-s (:in *index.css*)) :display flex :gap (:var --size-fluid-1) (button :width (:var --size-6) :height (:var --size-6) :font-size (:var --font-size-4) :align-self center)) (defun todo-element (todo) "A single todo element" (spinneret:with-html (:li :class (style-class todo-element-s) (:button :class (style-class nice-button) :hx-delete (format nil "/groups/~a/~a" (model:todo-group todo) (model:todo-order todo)) :hx-target "closest li" :hx-swap "outerHTML" "-") (model:todo-desc todo)))) (defcss (group-card-s (:in *index.css*)) :background (:var --secondary-background) :width 100% :padding (:var --size-3) :border-radius (:var --radius-3) :box-shadow (:var --shadow-2) (h3 :font-size (:var --font-size-3) :margin-top 0px) (ul :padding-left 0px :list-style-type none :line-height (:var --font-lineheight-5))) (defcss (todo-form (:in *index.css*)) :display flex :gap (:var --size-2) :height (:var --size-6) (input :background (:var --gray-1) :border (:var --border-size-1) solid (:var --gray-4) :flex-grow 1 :font-size (:var --font-size-3) :border-radius (:var --radius-2)) ((:and input :focus) :outline (:var --border-size-1) solid (:var --gray-9)) (button :width (:var --size-6) :font-size (:var --font-size-4))) (defun group-card (group todos) "A card containing many todos" (spinneret:with-html (:div :class (style-class group-card-s) (:h3 (model:group-desc group)) (:ul :hx-put (format nil "/groups/~a" (model:group-id group)) :hx-trigger "reordered" :hx-vals "js:{to: event.to, from: event.from, oldord: event.oldord, neword: event.neword}" :data-groupid (model:group-id group) :js-todos t (loop for todo in todos when (model:todo-order todo) collect (todo-element todo))) (:form :class (style-class todo-form) :hx-post (format nil "/groups/~a" (model:group-id group)) :hx-target "previous ul" :hx-swap "beforeend" (:input :name "desc") (:button :class (style-class nice-button) :type "submit" "+"))))) (defcss (group-container (:in *index.css*)) :display flex :flex-direction row :justify-content space-evenly :gap (:var --size-fluid-1)) (defun index (todos) (with-page ((:title "Todos") (:script :src "/vendor/sortable.js") (:script :defer "" :src "/js/index.js" "")) (:h1 "CL Trello") (:div :class (style-class group-container) (loop for (group . todos) in todos do (group-card group todos)))))
4,221
Common Lisp
.lisp
125
28.232
98
0.607617
cadrgtsecond/cl-trello
0
0
0
GPL-2.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
9885a688ad6c98a0b60d028fd27d99cd80c6808aeaada7f62914649d1dad2e8f
44,557
[ -1 ]
44,558
cl-trello.asd
cadrgtsecond_cl-trello/cl-trello.asd
(in-package :asdf-user) (defsystem "cl-trello" :description "A clone of Trello with Common Lisp and HTMX" :author "Abhinav Krishna <[email protected]>" :version "0.0.1" :depends-on (defcss spinneret ningle clack mito iterate alexandria str) :components ((:module "src" :serial t :components ((:file "model") (:file "templates") (:file "main")))))
453
Common Lisp
.asd
12
29
73
0.597727
cadrgtsecond/cl-trello
0
0
0
GPL-2.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
e743c8fdd4b7413fc4600cff12977dcb9822487181a302359035a3a54671d6b1
44,558
[ -1 ]
44,561
schema.sql
cadrgtsecond_cl-trello/schema.sql
PRAGMA recursive_triggers = 1; create trigger update_todo_order before update of "order" on todo begin update todo set "order" = "order" + 1 where "order" = new."order" and "group" = new."group"; end; create trigger insert_todo_order before insert on todo begin update todo set "order" = "order" + 1 where "order" = new."order" and "group" = new."group"; end; insert into todo ("order", desc, done_p, "group") values (0, 'Another test', 1, 1);
468
Common Lisp
.l
12
36
83
0.676923
cadrgtsecond/cl-trello
0
0
0
GPL-2.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
6ac14b1c099d7de3ddb1afafaf4589d9b64b563b26ec2a1985836ca050084554
44,561
[ -1 ]
44,565
sortable.js
cadrgtsecond_cl-trello/vendor/sortable.js
/*! Sortable 1.15.0 - MIT | git://github.com/SortableJS/Sortable.git */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Sortable=e()}(this,function(){"use strict";function e(e,t){var n,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function M(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?e(Object(i),!0).forEach(function(t){var e,n;e=o,t=i[n=t],n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n,o=arguments[e];for(n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t}).apply(this,arguments)}function i(t,e){if(null==t)return{};var n,o=function(t,e){if(null==t)return{};for(var n,o={},i=Object.keys(t),r=0;r<i.length;r++)n=i[r],0<=e.indexOf(n)||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols)for(var i=Object.getOwnPropertySymbols(t),r=0;r<i.length;r++)n=i[r],0<=e.indexOf(n)||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n]);return o}function r(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return l(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}function t(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var y=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),w=t(/Edge/i),s=t(/firefox/i),u=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),n=t(/iP(ad|od|hone)/i),c=t(/chrome/i)&&t(/android/i),d={capture:!1,passive:!1};function h(t,e,n){t.addEventListener(e,n,!y&&d)}function f(t,e,n){t.removeEventListener(e,n,!y&&d)}function p(t,e){if(e&&(">"===e[0]&&(e=e.substring(1)),t))try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return}}function N(t,e,n,o){if(t){n=n||document;do{if(null!=e&&(">"!==e[0]||t.parentNode===n)&&p(t,e)||o&&t===n)return t}while(t!==n&&(t=(i=t).host&&i!==document&&i.host.nodeType?i.host:i.parentNode))}var i;return null}var g,m=/\s+/g;function I(t,e,n){var o;t&&e&&(t.classList?t.classList[n?"add":"remove"](e):(o=(" "+t.className+" ").replace(m," ").replace(" "+e+" "," "),t.className=(o+(n?" "+e:"")).replace(m," ")))}function P(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];o[e=!(e in o||-1!==e.indexOf("webkit"))?"-webkit-"+e:e]=n+("string"==typeof n?"":"px")}}function v(t,e){var n="";if("string"==typeof t)n=t;else do{var o=P(t,"transform")}while(o&&"none"!==o&&(n=o+" "+n),!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function b(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i<r;i++)n(o[i],i);return o}return[]}function O(){var t=document.scrollingElement;return t||document.documentElement}function k(t,e,n,o,i){if(t.getBoundingClientRect||t===window){var r,a,l,s,c,u,d=t!==window&&t.parentNode&&t!==O()?(a=(r=t.getBoundingClientRect()).top,l=r.left,s=r.bottom,c=r.right,u=r.height,r.width):(l=a=0,s=window.innerHeight,c=window.innerWidth,u=window.innerHeight,window.innerWidth);if((e||n)&&t!==window&&(i=i||t.parentNode,!y))do{if(i&&i.getBoundingClientRect&&("none"!==P(i,"transform")||n&&"static"!==P(i,"position"))){var h=i.getBoundingClientRect();a-=h.top+parseInt(P(i,"border-top-width")),l-=h.left+parseInt(P(i,"border-left-width")),s=a+r.height,c=l+r.width;break}}while(i=i.parentNode);return o&&t!==window&&(o=(e=v(i||t))&&e.a,t=e&&e.d,e&&(s=(a/=t)+(u/=t),c=(l/=o)+(d/=o))),{top:a,left:l,bottom:s,right:c,width:d,height:u}}}function R(t,e,n){for(var o=A(t,!0),i=k(t)[e];o;){var r=k(o)[n];if(!("top"===n||"left"===n?r<=i:i<=r))return o;if(o===O())break;o=A(o,!1)}return!1}function X(t,e,n,o){for(var i=0,r=0,a=t.children;r<a.length;){if("none"!==a[r].style.display&&a[r]!==Bt.ghost&&(o||a[r]!==Bt.dragged)&&N(a[r],n.draggable,t,!1)){if(i===e)return a[r];i++}r++}return null}function Y(t,e){for(var n=t.lastElementChild;n&&(n===Bt.ghost||"none"===P(n,"display")||e&&!p(n,e));)n=n.previousElementSibling;return n||null}function B(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||t===Bt.clone||e&&!p(t,e)||n++;return n}function E(t){var e=0,n=0,o=O();if(t)do{var i=v(t),r=i.a,i=i.d}while(e+=t.scrollLeft*r,n+=t.scrollTop*i,t!==o&&(t=t.parentNode));return[e,n]}function A(t,e){if(!t||!t.getBoundingClientRect)return O();var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=P(n);if(n.clientWidth<n.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||n.clientHeight<n.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!n.getBoundingClientRect||n===document.body)return O();if(o||e)return n;o=!0}}}while(n=n.parentNode);return O()}function D(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}function S(e,n){return function(){var t;g||(1===(t=arguments).length?e.call(this,t[0]):e.apply(this,t),g=setTimeout(function(){g=void 0},n))}}function F(t,e,n){t.scrollLeft+=e,t.scrollTop+=n}function _(t){var e=window.Polymer,n=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):n?n(t).clone(!0)[0]:t.cloneNode(!0)}function C(t,e){P(t,"position","absolute"),P(t,"top",e.top),P(t,"left",e.left),P(t,"width",e.width),P(t,"height",e.height)}function T(t){P(t,"position",""),P(t,"top",""),P(t,"left",""),P(t,"width",""),P(t,"height","")}var j="Sortable"+(new Date).getTime();function x(){var e,o=[];return{captureAnimationState:function(){o=[],this.options.animation&&[].slice.call(this.el.children).forEach(function(t){var e,n;"none"!==P(t,"display")&&t!==Bt.ghost&&(o.push({target:t,rect:k(t)}),e=M({},o[o.length-1].rect),!t.thisAnimationDuration||(n=v(t,!0))&&(e.top-=n.f,e.left-=n.e),t.fromRect=e)})},addAnimationState:function(t){o.push(t)},removeAnimationState:function(t){o.splice(function(t,e){for(var n in t)if(t.hasOwnProperty(n))for(var o in e)if(e.hasOwnProperty(o)&&e[o]===t[n][o])return Number(n);return-1}(o,{target:t}),1)},animateAll:function(t){var c=this;if(!this.options.animation)return clearTimeout(e),void("function"==typeof t&&t());var u=!1,d=0;o.forEach(function(t){var e=0,n=t.target,o=n.fromRect,i=k(n),r=n.prevFromRect,a=n.prevToRect,l=t.rect,s=v(n,!0);s&&(i.top-=s.f,i.left-=s.e),n.toRect=i,n.thisAnimationDuration&&D(r,i)&&!D(o,i)&&(l.top-i.top)/(l.left-i.left)==(o.top-i.top)/(o.left-i.left)&&(t=l,s=r,r=a,a=c.options,e=Math.sqrt(Math.pow(s.top-t.top,2)+Math.pow(s.left-t.left,2))/Math.sqrt(Math.pow(s.top-r.top,2)+Math.pow(s.left-r.left,2))*a.animation),D(i,o)||(n.prevFromRect=o,n.prevToRect=i,e=e||c.options.animation,c.animate(n,l,i,e)),e&&(u=!0,d=Math.max(d,e),clearTimeout(n.animationResetTimer),n.animationResetTimer=setTimeout(function(){n.animationTime=0,n.prevFromRect=null,n.fromRect=null,n.prevToRect=null,n.thisAnimationDuration=null},e),n.thisAnimationDuration=e)}),clearTimeout(e),u?e=setTimeout(function(){"function"==typeof t&&t()},d):"function"==typeof t&&t(),o=[]},animate:function(t,e,n,o){var i,r;o&&(P(t,"transition",""),P(t,"transform",""),i=(r=v(this.el))&&r.a,r=r&&r.d,i=(e.left-n.left)/(i||1),r=(e.top-n.top)/(r||1),t.animatingX=!!i,t.animatingY=!!r,P(t,"transform","translate3d("+i+"px,"+r+"px,0)"),this.forRepaintDummy=t.offsetWidth,P(t,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),P(t,"transform","translate3d(0,0,0)"),"number"==typeof t.animated&&clearTimeout(t.animated),t.animated=setTimeout(function(){P(t,"transition",""),P(t,"transform",""),t.animated=!1,t.animatingX=!1,t.animatingY=!1},o))}}}var H=[],L={initializeByDefault:!0},K={mount:function(e){for(var t in L)!L.hasOwnProperty(t)||t in e||(e[t]=L[t]);H.forEach(function(t){if(t.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),H.push(e)},pluginEvent:function(e,n,o){var t=this;this.eventCanceled=!1,o.cancel=function(){t.eventCanceled=!0};var i=e+"Global";H.forEach(function(t){n[t.pluginName]&&(n[t.pluginName][i]&&n[t.pluginName][i](M({sortable:n},o)),n.options[t.pluginName]&&n[t.pluginName][e]&&n[t.pluginName][e](M({sortable:n},o)))})},initializePlugins:function(n,o,i,t){for(var e in H.forEach(function(t){var e=t.pluginName;(n.options[e]||t.initializeByDefault)&&((t=new t(n,o,n.options)).sortable=n,t.options=n.options,n[e]=t,a(i,t.defaults))}),n.options){var r;n.options.hasOwnProperty(e)&&(void 0!==(r=this.modifyOption(n,e,n.options[e]))&&(n.options[e]=r))}},getEventProperties:function(e,n){var o={};return H.forEach(function(t){"function"==typeof t.eventProperties&&a(o,t.eventProperties.call(n[t.pluginName],e))}),o},modifyOption:function(e,n,o){var i;return H.forEach(function(t){e[t.pluginName]&&t.optionListeners&&"function"==typeof t.optionListeners[n]&&(i=t.optionListeners[n].call(e[t.pluginName],o))}),i}};function W(t){var e=t.sortable,n=t.rootEl,o=t.name,i=t.targetEl,r=t.cloneEl,a=t.toEl,l=t.fromEl,s=t.oldIndex,c=t.newIndex,u=t.oldDraggableIndex,d=t.newDraggableIndex,h=t.originalEvent,f=t.putSortable,p=t.extraEventProperties;if(e=e||n&&n[j]){var g,m=e.options,t="on"+o.charAt(0).toUpperCase()+o.substr(1);!window.CustomEvent||y||w?(g=document.createEvent("Event")).initEvent(o,!0,!0):g=new CustomEvent(o,{bubbles:!0,cancelable:!0}),g.to=a||n,g.from=l||n,g.item=i||n,g.clone=r,g.oldIndex=s,g.newIndex=c,g.oldDraggableIndex=u,g.newDraggableIndex=d,g.originalEvent=h,g.pullMode=f?f.lastPutMode:void 0;var v,b=M(M({},p),K.getEventProperties(o,e));for(v in b)g[v]=b[v];n&&n.dispatchEvent(g),m[t]&&m[t].call(e,g)}}function z(t,e){var n=(o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).evt,o=i(o,G);K.pluginEvent.bind(Bt)(t,e,M({dragEl:q,parentEl:V,ghostEl:Z,rootEl:$,nextEl:Q,lastDownEl:J,cloneEl:tt,cloneHidden:et,dragStarted:pt,putSortable:lt,activeSortable:Bt.active,originalEvent:n,oldIndex:nt,oldDraggableIndex:it,newIndex:ot,newDraggableIndex:rt,hideGhostForTarget:kt,unhideGhostForTarget:Rt,cloneNowHidden:function(){et=!0},cloneNowShown:function(){et=!1},dispatchSortableEvent:function(t){U({sortable:e,name:t,originalEvent:n})}},o))}var G=["evt"];function U(t){W(M({putSortable:lt,cloneEl:tt,targetEl:q,rootEl:$,oldIndex:nt,oldDraggableIndex:it,newIndex:ot,newDraggableIndex:rt},t))}var q,V,Z,$,Q,J,tt,et,nt,ot,it,rt,at,lt,st,ct,ut,dt,ht,ft,pt,gt,mt,vt,bt,yt=!1,wt=!1,Et=[],Dt=!1,St=!1,_t=[],Ct=!1,Tt=[],xt="undefined"!=typeof document,Ot=n,At=w||y?"cssFloat":"float",Mt=xt&&!c&&!n&&"draggable"in document.createElement("div"),Nt=function(){if(xt){if(y)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}}(),It=function(t,e){var n=P(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=X(t,0,e),r=X(t,1,e),a=i&&P(i),l=r&&P(r),s=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+k(i).width,t=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+k(r).width;if("flex"===n.display)return"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal";if("grid"===n.display)return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&a.float&&"none"!==a.float){e="left"===a.float?"left":"right";return!r||"both"!==l.clear&&l.clear!==e?"horizontal":"vertical"}return i&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||o<=s&&"none"===n[At]||r&&"none"===n[At]&&o<s+t)?"vertical":"horizontal"},Pt=function(t){function l(r,a){return function(t,e,n,o){var i=t.options.group.name&&e.options.group.name&&t.options.group.name===e.options.group.name;if(null==r&&(a||i))return!0;if(null==r||!1===r)return!1;if(a&&"clone"===r)return r;if("function"==typeof r)return l(r(t,e,n,o),a)(t,e,n,o);e=(a?t:e).options.group.name;return!0===r||"string"==typeof r&&r===e||r.join&&-1<r.indexOf(e)}}var e={},n=t.group;n&&"object"==o(n)||(n={name:n}),e.name=n.name,e.checkPull=l(n.pull,!0),e.checkPut=l(n.put),e.revertClone=n.revertClone,t.group=e},kt=function(){!Nt&&Z&&P(Z,"display","none")},Rt=function(){!Nt&&Z&&P(Z,"display","")};xt&&!c&&document.addEventListener("click",function(t){if(wt)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),wt=!1},!0);function Xt(t){if(q){t=t.touches?t.touches[0]:t;var e=(i=t.clientX,r=t.clientY,Et.some(function(t){var e=t[j].options.emptyInsertThreshold;if(e&&!Y(t)){var n=k(t),o=i>=n.left-e&&i<=n.right+e,e=r>=n.top-e&&r<=n.bottom+e;return o&&e?a=t:void 0}}),a);if(e){var n,o={};for(n in t)t.hasOwnProperty(n)&&(o[n]=t[n]);o.target=o.rootEl=e,o.preventDefault=void 0,o.stopPropagation=void 0,e[j]._onDragOver(o)}}var i,r,a}function Yt(t){q&&q.parentNode[j]._isOutsideThisEl(t.target)}function Bt(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=a({},e),t[j]=this;var n,o,i={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return It(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==Bt.supportPointer&&"PointerEvent"in window&&!u,emptyInsertThreshold:5};for(n in K.initializePlugins(this,t,i),i)n in e||(e[n]=i[n]);for(o in Pt(e),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));this.nativeDraggable=!e.forceFallback&&Mt,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?h(t,"pointerdown",this._onTapStart):(h(t,"mousedown",this._onTapStart),h(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(h(t,"dragover",this),h(t,"dragenter",this)),Et.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),a(this,x())}function Ft(t,e,n,o,i,r,a,l){var s,c,u=t[j],d=u.options.onMove;return!window.CustomEvent||y||w?(s=document.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=n,s.draggedRect=o,s.related=i||e,s.relatedRect=r||k(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),c=d?d.call(u,s,a):c}function jt(t){t.draggable=!1}function Ht(){Ct=!1}function Lt(t){return setTimeout(t,0)}function Kt(t){return clearTimeout(t)}Bt.prototype={constructor:Bt,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(gt=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,q):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n=this,o=this.el,t=this.options,i=t.preventOnFilter,r=e.type,a=e.touches&&e.touches[0]||e.pointerType&&"touch"===e.pointerType&&e,l=(a||e).target,s=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=t.filter;if(!function(t){Tt.length=0;var e=t.getElementsByTagName("input"),n=e.length;for(;n--;){var o=e[n];o.checked&&Tt.push(o)}}(o),!q&&!(/mousedown|pointerdown/.test(r)&&0!==e.button||t.disabled)&&!s.isContentEditable&&(this.nativeDraggable||!u||!l||"SELECT"!==l.tagName.toUpperCase())&&!((l=N(l,t.draggable,o,!1))&&l.animated||J===l)){if(nt=B(l),it=B(l,t.draggable),"function"==typeof c){if(c.call(this,e,l,this))return U({sortable:n,rootEl:s,name:"filter",targetEl:l,toEl:o,fromEl:o}),z("filter",n,{evt:e}),void(i&&e.cancelable&&e.preventDefault())}else if(c=c&&c.split(",").some(function(t){if(t=N(s,t.trim(),o,!1))return U({sortable:n,rootEl:t,name:"filter",targetEl:l,fromEl:o,toEl:o}),z("filter",n,{evt:e}),!0}))return void(i&&e.cancelable&&e.preventDefault());t.handle&&!N(s,t.handle,o,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,a=i.options,l=r.ownerDocument;n&&!q&&n.parentNode===r&&(o=k(n),$=r,V=(q=n).parentNode,Q=q.nextSibling,J=n,at=a.group,st={target:Bt.dragged=q,clientX:(e||t).clientX,clientY:(e||t).clientY},ht=st.clientX-o.left,ft=st.clientY-o.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,q.style["will-change"]="all",o=function(){z("delayEnded",i,{evt:t}),Bt.eventCanceled?i._onDrop():(i._disableDelayedDragEvents(),!s&&i.nativeDraggable&&(q.draggable=!0),i._triggerDragStart(t,e),U({sortable:i,name:"choose",originalEvent:t}),I(q,a.chosenClass,!0))},a.ignore.split(",").forEach(function(t){b(q,t.trim(),jt)}),h(l,"dragover",Xt),h(l,"mousemove",Xt),h(l,"touchmove",Xt),h(l,"mouseup",i._onDrop),h(l,"touchend",i._onDrop),h(l,"touchcancel",i._onDrop),s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,q.draggable=!0),z("delayStart",this,{evt:t}),!a.delay||a.delayOnTouchOnly&&!e||this.nativeDraggable&&(w||y)?o():Bt.eventCanceled?this._onDrop():(h(l,"mouseup",i._disableDelayedDrag),h(l,"touchend",i._disableDelayedDrag),h(l,"touchcancel",i._disableDelayedDrag),h(l,"mousemove",i._delayedDragTouchMoveHandler),h(l,"touchmove",i._delayedDragTouchMoveHandler),a.supportPointer&&h(l,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(o,a.delay)))},_delayedDragTouchMoveHandler:function(t){t=t.touches?t.touches[0]:t;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){q&&jt(q),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;f(t,"mouseup",this._disableDelayedDrag),f(t,"touchend",this._disableDelayedDrag),f(t,"touchcancel",this._disableDelayedDrag),f(t,"mousemove",this._delayedDragTouchMoveHandler),f(t,"touchmove",this._delayedDragTouchMoveHandler),f(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?h(document,"pointermove",this._onTouchMove):h(document,e?"touchmove":"mousemove",this._onTouchMove):(h(q,"dragend",this),h($,"dragstart",this._onDragStart));try{document.selection?Lt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){var n;yt=!1,$&&q?(z("dragStarted",this,{evt:e}),this.nativeDraggable&&h(document,"dragover",Yt),n=this.options,t||I(q,n.dragClass,!1),I(q,n.ghostClass,!0),Bt.active=this,t&&this._appendGhost(),U({sortable:this,name:"start",originalEvent:e})):this._nulling()},_emulateDragOver:function(){if(ct){this._lastX=ct.clientX,this._lastY=ct.clientY,kt();for(var t=document.elementFromPoint(ct.clientX,ct.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(ct.clientX,ct.clientY))!==e;)e=t;if(q.parentNode[j]._isOutsideThisEl(t),e)do{if(e[j])if(e[j]._onDragOver({clientX:ct.clientX,clientY:ct.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}while(e=(t=e).parentNode);Rt()}},_onTouchMove:function(t){if(st){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=Z&&v(Z,!0),a=Z&&r&&r.a,l=Z&&r&&r.d,e=Ot&&bt&&E(bt),a=(i.clientX-st.clientX+o.x)/(a||1)+(e?e[0]-_t[0]:0)/(a||1),l=(i.clientY-st.clientY+o.y)/(l||1)+(e?e[1]-_t[1]:0)/(l||1);if(!Bt.active&&!yt){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}Z&&(r?(r.e+=a-(ut||0),r.f+=l-(dt||0)):r={a:1,b:0,c:0,d:1,e:a,f:l},r="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")"),P(Z,"webkitTransform",r),P(Z,"mozTransform",r),P(Z,"msTransform",r),P(Z,"transform",r),ut=a,dt=l,ct=i),t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!Z){var t=this.options.fallbackOnBody?document.body:$,e=k(q,!0,Ot,!0,t),n=this.options;if(Ot){for(bt=t;"static"===P(bt,"position")&&"none"===P(bt,"transform")&&bt!==document;)bt=bt.parentNode;bt!==document.body&&bt!==document.documentElement?(bt===document&&(bt=O()),e.top+=bt.scrollTop,e.left+=bt.scrollLeft):bt=O(),_t=E(bt)}I(Z=q.cloneNode(!0),n.ghostClass,!1),I(Z,n.fallbackClass,!0),I(Z,n.dragClass,!0),P(Z,"transition",""),P(Z,"transform",""),P(Z,"box-sizing","border-box"),P(Z,"margin",0),P(Z,"top",e.top),P(Z,"left",e.left),P(Z,"width",e.width),P(Z,"height",e.height),P(Z,"opacity","0.8"),P(Z,"position",Ot?"absolute":"fixed"),P(Z,"zIndex","100000"),P(Z,"pointerEvents","none"),Bt.ghost=Z,t.appendChild(Z),P(Z,"transform-origin",ht/parseInt(Z.style.width)*100+"% "+ft/parseInt(Z.style.height)*100+"%")}},_onDragStart:function(t,e){var n=this,o=t.dataTransfer,i=n.options;z("dragStart",this,{evt:t}),Bt.eventCanceled?this._onDrop():(z("setupClone",this),Bt.eventCanceled||((tt=_(q)).removeAttribute("id"),tt.draggable=!1,tt.style["will-change"]="",this._hideClone(),I(tt,this.options.chosenClass,!1),Bt.clone=tt),n.cloneId=Lt(function(){z("clone",n),Bt.eventCanceled||(n.options.removeCloneOnHide||$.insertBefore(tt,q),n._hideClone(),U({sortable:n,name:"clone"}))}),e||I(q,i.dragClass,!0),e?(wt=!0,n._loopId=setInterval(n._emulateDragOver,50)):(f(document,"mouseup",n._onDrop),f(document,"touchend",n._onDrop),f(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",i.setData&&i.setData.call(n,o,q)),h(document,"drop",n),P(q,"transform","translateZ(0)")),yt=!0,n._dragStartId=Lt(n._dragStarted.bind(n,e,t)),h(document,"selectstart",n),pt=!0,u&&P(document.body,"user-select","none"))},_onDragOver:function(n){var o,i,r,t,a=this.el,l=n.target,e=this.options,s=e.group,c=Bt.active,u=at===s,d=e.sort,h=lt||c,f=this,p=!1;if(!Ct){if(void 0!==n.preventDefault&&n.cancelable&&n.preventDefault(),l=N(l,e.draggable,a,!0),T("dragOver"),Bt.eventCanceled)return p;if(q.contains(n.target)||l.animated&&l.animatingX&&l.animatingY||f._ignoreWhileAnimating===l)return O(!1);if(wt=!1,c&&!e.disabled&&(u?d||(i=V!==$):lt===this||(this.lastPutMode=at.checkPull(this,c,q,n))&&s.checkPut(this,c,q,n))){if(r="vertical"===this._getDirection(n,l),o=k(q),T("dragOverValid"),Bt.eventCanceled)return p;if(i)return V=$,x(),this._hideClone(),T("revert"),Bt.eventCanceled||(Q?$.insertBefore(q,Q):$.appendChild(q)),O(!0);var g=Y(a,e.draggable);if(!g||function(t,e,n){n=k(Y(n.el,n.options.draggable));return e?t.clientX>n.right+10||t.clientX<=n.right&&t.clientY>n.bottom&&t.clientX>=n.left:t.clientX>n.right&&t.clientY>n.top||t.clientX<=n.right&&t.clientY>n.bottom+10}(n,r,this)&&!g.animated){if(g===q)return O(!1);if((l=g&&a===n.target?g:l)&&(w=k(l)),!1!==Ft($,a,q,o,l,w,n,!!l))return x(),g&&g.nextSibling?a.insertBefore(q,g.nextSibling):a.appendChild(q),V=a,A(),O(!0)}else if(g&&function(t,e,n){n=k(X(n.el,0,n.options,!0));return e?t.clientX<n.left-10||t.clientY<n.top&&t.clientX<n.right:t.clientY<n.top-10||t.clientY<n.bottom&&t.clientX<n.left}(n,r,this)){var m=X(a,0,e,!0);if(m===q)return O(!1);if(w=k(l=m),!1!==Ft($,a,q,o,l,w,n,!1))return x(),a.insertBefore(q,m),V=a,A(),O(!0)}else if(l.parentNode===a){var v,b,y,w=k(l),E=q.parentNode!==a,D=(D=q.animated&&q.toRect||o,C=l.animated&&l.toRect||w,S=(t=r)?D.left:D.top,s=t?D.right:D.bottom,g=t?D.width:D.height,m=t?C.left:C.top,D=t?C.right:C.bottom,C=t?C.width:C.height,!(S===m||s===D||S+g/2===m+C/2)),S=r?"top":"left",g=R(l,"top","top")||R(q,"top","top"),m=g?g.scrollTop:void 0;if(gt!==l&&(b=w[S],Dt=!1,St=!D&&e.invertSwap||E),0!==(v=function(t,e,n,o,i,r,a,l){var s=o?t.clientY:t.clientX,c=o?n.height:n.width,t=o?n.top:n.left,o=o?n.bottom:n.right,n=!1;if(!a)if(l&&vt<c*i){if(Dt=!Dt&&(1===mt?t+c*r/2<s:s<o-c*r/2)?!0:Dt)n=!0;else if(1===mt?s<t+vt:o-vt<s)return-mt}else if(t+c*(1-i)/2<s&&s<o-c*(1-i)/2)return function(t){return B(q)<B(t)?1:-1}(e);if((n=n||a)&&(s<t+c*r/2||o-c*r/2<s))return t+c/2<s?1:-1;return 0}(n,l,w,r,D?1:e.swapThreshold,null==e.invertedSwapThreshold?e.swapThreshold:e.invertedSwapThreshold,St,gt===l)))for(var _=B(q);(y=V.children[_-=v])&&("none"===P(y,"display")||y===Z););if(0===v||y===l)return O(!1);mt=v;var C=(gt=l).nextElementSibling,E=!1,D=Ft($,a,q,o,l,w,n,E=1===v);if(!1!==D)return 1!==D&&-1!==D||(E=1===D),Ct=!0,setTimeout(Ht,30),x(),E&&!C?a.appendChild(q):l.parentNode.insertBefore(q,E?C:l),g&&F(g,0,m-g.scrollTop),V=q.parentNode,void 0===b||St||(vt=Math.abs(b-k(l)[S])),A(),O(!0)}if(a.contains(q))return O(!1)}return!1}function T(t,e){z(t,f,M({evt:n,isOwner:u,axis:r?"vertical":"horizontal",revert:i,dragRect:o,targetRect:w,canSort:d,fromSortable:h,target:l,completed:O,onMove:function(t,e){return Ft($,a,q,o,t,k(t),n,e)},changed:A},e))}function x(){T("dragOverAnimationCapture"),f.captureAnimationState(),f!==h&&h.captureAnimationState()}function O(t){return T("dragOverCompleted",{insertion:t}),t&&(u?c._hideClone():c._showClone(f),f!==h&&(I(q,(lt||c).options.ghostClass,!1),I(q,e.ghostClass,!0)),lt!==f&&f!==Bt.active?lt=f:f===Bt.active&&lt&&(lt=null),h===f&&(f._ignoreWhileAnimating=l),f.animateAll(function(){T("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(l===q&&!q.animated||l===a&&!l.animated)&&(gt=null),e.dragoverBubble||n.rootEl||l===document||(q.parentNode[j]._isOutsideThisEl(n.target),t||Xt(n)),!e.dragoverBubble&&n.stopPropagation&&n.stopPropagation(),p=!0}function A(){ot=B(q),rt=B(q,e.draggable),U({sortable:f,name:"change",toEl:a,newIndex:ot,newDraggableIndex:rt,originalEvent:n})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){f(document,"mousemove",this._onTouchMove),f(document,"touchmove",this._onTouchMove),f(document,"pointermove",this._onTouchMove),f(document,"dragover",Xt),f(document,"mousemove",Xt),f(document,"touchmove",Xt)},_offUpEvents:function(){var t=this.el.ownerDocument;f(t,"mouseup",this._onDrop),f(t,"touchend",this._onDrop),f(t,"pointerup",this._onDrop),f(t,"touchcancel",this._onDrop),f(document,"selectstart",this)},_onDrop:function(t){var e=this.el,n=this.options;ot=B(q),rt=B(q,n.draggable),z("drop",this,{evt:t}),V=q&&q.parentNode,ot=B(q),rt=B(q,n.draggable),Bt.eventCanceled||(Dt=St=yt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Kt(this.cloneId),Kt(this._dragStartId),this.nativeDraggable&&(f(document,"drop",this),f(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),u&&P(document.body,"user-select",""),P(q,"transform",""),t&&(pt&&(t.cancelable&&t.preventDefault(),n.dropBubble||t.stopPropagation()),Z&&Z.parentNode&&Z.parentNode.removeChild(Z),($===V||lt&&"clone"!==lt.lastPutMode)&&tt&&tt.parentNode&&tt.parentNode.removeChild(tt),q&&(this.nativeDraggable&&f(q,"dragend",this),jt(q),q.style["will-change"]="",pt&&!yt&&I(q,(lt||this).options.ghostClass,!1),I(q,this.options.chosenClass,!1),U({sortable:this,name:"unchoose",toEl:V,newIndex:null,newDraggableIndex:null,originalEvent:t}),$!==V?(0<=ot&&(U({rootEl:V,name:"add",toEl:V,fromEl:$,originalEvent:t}),U({sortable:this,name:"remove",toEl:V,originalEvent:t}),U({rootEl:V,name:"sort",toEl:V,fromEl:$,originalEvent:t}),U({sortable:this,name:"sort",toEl:V,originalEvent:t})),lt&&lt.save()):ot!==nt&&0<=ot&&(U({sortable:this,name:"update",toEl:V,originalEvent:t}),U({sortable:this,name:"sort",toEl:V,originalEvent:t})),Bt.active&&(null!=ot&&-1!==ot||(ot=nt,rt=it),U({sortable:this,name:"end",toEl:V,originalEvent:t}),this.save())))),this._nulling()},_nulling:function(){z("nulling",this),$=q=V=Z=Q=tt=J=et=st=ct=pt=ot=rt=nt=it=gt=mt=lt=at=Bt.dragged=Bt.ghost=Bt.clone=Bt.active=null,Tt.forEach(function(t){t.checked=!0}),Tt.length=ut=dt=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":q&&(this._onDragOver(t),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],n=this.el.children,o=0,i=n.length,r=this.options;o<i;o++)N(t=n[o],r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||function(t){var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;for(;n--;)o+=e.charCodeAt(n);return o.toString(36)}(t));return e},sort:function(t,e){var n={},o=this.el;this.toArray().forEach(function(t,e){e=o.children[e];N(e,this.options.draggable,o,!1)&&(n[t]=e)},this),e&&this.captureAnimationState(),t.forEach(function(t){n[t]&&(o.removeChild(n[t]),o.appendChild(n[t]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return N(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var n=this.options;if(void 0===e)return n[t];var o=K.modifyOption(this,t,e);n[t]=void 0!==o?o:e,"group"===t&&Pt(n)},destroy:function(){z("destroy",this);var t=this.el;t[j]=null,f(t,"mousedown",this._onTapStart),f(t,"touchstart",this._onTapStart),f(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(f(t,"dragover",this),f(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Et.splice(Et.indexOf(this.el),1),this.el=t=null},_hideClone:function(){et||(z("hideClone",this),Bt.eventCanceled||(P(tt,"display","none"),this.options.removeCloneOnHide&&tt.parentNode&&tt.parentNode.removeChild(tt),et=!0))},_showClone:function(t){"clone"===t.lastPutMode?et&&(z("showClone",this),Bt.eventCanceled||(q.parentNode!=$||this.options.group.revertClone?Q?$.insertBefore(tt,Q):$.appendChild(tt):$.insertBefore(tt,q),this.options.group.revertClone&&this.animate(q,tt),P(tt,"display",""),et=!1)):this._hideClone()}},xt&&h(document,"touchmove",function(t){(Bt.active||yt)&&t.cancelable&&t.preventDefault()}),Bt.utils={on:h,off:f,css:P,find:b,is:function(t,e){return!!N(t,e,t,!1)},extend:function(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},throttle:S,closest:N,toggleClass:I,clone:_,index:B,nextTick:Lt,cancelNextTick:Kt,detectDirection:It,getChild:X},Bt.get=function(t){return t[j]},Bt.mount=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];(e=e[0].constructor===Array?e[0]:e).forEach(function(t){if(!t.prototype||!t.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(t));t.utils&&(Bt.utils=M(M({},Bt.utils),t.utils)),K.mount(t)})},Bt.create=function(t,e){return new Bt(t,e)};var Wt,zt,Gt,Ut,qt,Vt,Zt=[],$t=!(Bt.version="1.15.0");function Qt(){Zt.forEach(function(t){clearInterval(t.pid)}),Zt=[]}function Jt(){clearInterval(Vt)}var te,ee=S(function(n,t,e,o){if(t.scroll){var i,r=(n.touches?n.touches[0]:n).clientX,a=(n.touches?n.touches[0]:n).clientY,l=t.scrollSensitivity,s=t.scrollSpeed,c=O(),u=!1;zt!==e&&(zt=e,Qt(),Wt=t.scroll,i=t.scrollFn,!0===Wt&&(Wt=A(e,!0)));var d=0,h=Wt;do{var f=h,p=k(f),g=p.top,m=p.bottom,v=p.left,b=p.right,y=p.width,w=p.height,E=void 0,D=void 0,S=f.scrollWidth,_=f.scrollHeight,C=P(f),T=f.scrollLeft,p=f.scrollTop,D=f===c?(E=y<S&&("auto"===C.overflowX||"scroll"===C.overflowX||"visible"===C.overflowX),w<_&&("auto"===C.overflowY||"scroll"===C.overflowY||"visible"===C.overflowY)):(E=y<S&&("auto"===C.overflowX||"scroll"===C.overflowX),w<_&&("auto"===C.overflowY||"scroll"===C.overflowY)),T=E&&(Math.abs(b-r)<=l&&T+y<S)-(Math.abs(v-r)<=l&&!!T),p=D&&(Math.abs(m-a)<=l&&p+w<_)-(Math.abs(g-a)<=l&&!!p);if(!Zt[d])for(var x=0;x<=d;x++)Zt[x]||(Zt[x]={});Zt[d].vx==T&&Zt[d].vy==p&&Zt[d].el===f||(Zt[d].el=f,Zt[d].vx=T,Zt[d].vy=p,clearInterval(Zt[d].pid),0==T&&0==p||(u=!0,Zt[d].pid=setInterval(function(){o&&0===this.layer&&Bt.active._onTouchMove(qt);var t=Zt[this.layer].vy?Zt[this.layer].vy*s:0,e=Zt[this.layer].vx?Zt[this.layer].vx*s:0;"function"==typeof i&&"continue"!==i.call(Bt.dragged.parentNode[j],e,t,n,qt,Zt[this.layer].el)||F(Zt[this.layer].el,e,t)}.bind({layer:d}),24))),d++}while(t.bubbleScroll&&h!==c&&(h=A(h,!1)));$t=u}},30),c=function(t){var e=t.originalEvent,n=t.putSortable,o=t.dragEl,i=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,t=t.unhideGhostForTarget;e&&(i=n||i,a(),e=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,e=document.elementFromPoint(e.clientX,e.clientY),t(),i&&!i.el.contains(e)&&(r("spill"),this.onSpill({dragEl:o,putSortable:n})))};function ne(){}function oe(){}ne.prototype={startIndex:null,dragStart:function(t){t=t.oldDraggableIndex;this.startIndex=t},onSpill:function(t){var e=t.dragEl,n=t.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();t=X(this.sortable.el,this.startIndex,this.options);t?this.sortable.el.insertBefore(e,t):this.sortable.el.appendChild(e),this.sortable.animateAll(),n&&n.animateAll()},drop:c},a(ne,{pluginName:"revertOnSpill"}),oe.prototype={onSpill:function(t){var e=t.dragEl,t=t.putSortable||this.sortable;t.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),t.animateAll()},drop:c},a(oe,{pluginName:"removeOnSpill"});var ie,re,ae,le,se,ce=[],ue=[],de=!1,he=!1,fe=!1;function pe(n,o){ue.forEach(function(t,e){e=o.children[t.sortableIndex+(n?Number(e):0)];e?o.insertBefore(t,e):o.appendChild(t)})}function ge(){ce.forEach(function(t){t!==ae&&t.parentNode&&t.parentNode.removeChild(t)})}return Bt.mount(new function(){function t(){for(var t in this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0},this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this))}return t.prototype={dragStarted:function(t){t=t.originalEvent;this.sortable.nativeDraggable?h(document,"dragover",this._handleAutoScroll):this.options.supportPointer?h(document,"pointermove",this._handleFallbackAutoScroll):t.touches?h(document,"touchmove",this._handleFallbackAutoScroll):h(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){t=t.originalEvent;this.options.dragOverBubble||t.rootEl||this._handleAutoScroll(t)},drop:function(){this.sortable.nativeDraggable?f(document,"dragover",this._handleAutoScroll):(f(document,"pointermove",this._handleFallbackAutoScroll),f(document,"touchmove",this._handleFallbackAutoScroll),f(document,"mousemove",this._handleFallbackAutoScroll)),Jt(),Qt(),clearTimeout(g),g=void 0},nulling:function(){qt=zt=Wt=$t=Vt=Gt=Ut=null,Zt.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(e,n){var o,i=this,r=(e.touches?e.touches[0]:e).clientX,a=(e.touches?e.touches[0]:e).clientY,t=document.elementFromPoint(r,a);qt=e,n||this.options.forceAutoScrollFallback||w||y||u?(ee(e,this.options,t,n),o=A(t,!0),!$t||Vt&&r===Gt&&a===Ut||(Vt&&Jt(),Vt=setInterval(function(){var t=A(document.elementFromPoint(r,a),!0);t!==o&&(o=t,Qt()),ee(e,i.options,t,n)},10),Gt=r,Ut=a)):this.options.bubbleScroll&&A(t,!0)!==O()?ee(e,this.options,A(t,!1),!1):Qt()}},a(t,{pluginName:"scroll",initializeByDefault:!0})}),Bt.mount(oe,ne),Bt.mount(new function(){function t(){this.defaults={swapClass:"sortable-swap-highlight"}}return t.prototype={dragStart:function(t){t=t.dragEl;te=t},dragOverValid:function(t){var e=t.completed,n=t.target,o=t.onMove,i=t.activeSortable,r=t.changed,a=t.cancel;i.options.swap&&(t=this.sortable.el,i=this.options,n&&n!==t&&(t=te,te=!1!==o(n)?(I(n,i.swapClass,!0),n):null,t&&t!==te&&I(t,i.swapClass,!1)),r(),e(!0),a())},drop:function(t){var e,n,o=t.activeSortable,i=t.putSortable,r=t.dragEl,a=i||this.sortable,l=this.options;te&&I(te,l.swapClass,!1),te&&(l.swap||i&&i.options.swap)&&r!==te&&(a.captureAnimationState(),a!==o&&o.captureAnimationState(),n=te,t=(e=r).parentNode,l=n.parentNode,t&&l&&!t.isEqualNode(n)&&!l.isEqualNode(e)&&(i=B(e),r=B(n),t.isEqualNode(l)&&i<r&&r++,t.insertBefore(n,t.children[i]),l.insertBefore(e,l.children[r])),a.animateAll(),a!==o&&o.animateAll())},nulling:function(){te=null}},a(t,{pluginName:"swap",eventProperties:function(){return{swapItem:te}}})}),Bt.mount(new function(){function t(o){for(var t in this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this));o.options.avoidImplicitDeselect||(o.options.supportPointer?h(document,"pointerup",this._deselectMultiDrag):(h(document,"mouseup",this._deselectMultiDrag),h(document,"touchend",this._deselectMultiDrag))),h(document,"keydown",this._checkKeyDown),h(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(t,e){var n="";ce.length&&re===o?ce.forEach(function(t,e){n+=(e?", ":"")+t.textContent}):n=e.textContent,t.setData("Text",n)}}}return t.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){t=t.dragEl;ae=t},delayEnded:function(){this.isMultiDrag=~ce.indexOf(ae)},setupClone:function(t){var e=t.sortable,t=t.cancel;if(this.isMultiDrag){for(var n=0;n<ce.length;n++)ue.push(_(ce[n])),ue[n].sortableIndex=ce[n].sortableIndex,ue[n].draggable=!1,ue[n].style["will-change"]="",I(ue[n],this.options.selectedClass,!1),ce[n]===ae&&I(ue[n],this.options.chosenClass,!1);e._hideClone(),t()}},clone:function(t){var e=t.sortable,n=t.rootEl,o=t.dispatchSortableEvent,t=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||ce.length&&re===e&&(pe(!0,n),o("clone"),t()))},showClone:function(t){var e=t.cloneNowShown,n=t.rootEl,t=t.cancel;this.isMultiDrag&&(pe(!1,n),ue.forEach(function(t){P(t,"display","")}),e(),se=!1,t())},hideClone:function(t){var e=this,n=(t.sortable,t.cloneNowHidden),t=t.cancel;this.isMultiDrag&&(ue.forEach(function(t){P(t,"display","none"),e.options.removeCloneOnHide&&t.parentNode&&t.parentNode.removeChild(t)}),n(),se=!0,t())},dragStartGlobal:function(t){t.sortable;!this.isMultiDrag&&re&&re.multiDrag._deselectMultiDrag(),ce.forEach(function(t){t.sortableIndex=B(t)}),ce=ce.sort(function(t,e){return t.sortableIndex-e.sortableIndex}),fe=!0},dragStarted:function(t){var e,n=this,t=t.sortable;this.isMultiDrag&&(this.options.sort&&(t.captureAnimationState(),this.options.animation&&(ce.forEach(function(t){t!==ae&&P(t,"position","absolute")}),e=k(ae,!1,!0,!0),ce.forEach(function(t){t!==ae&&C(t,e)}),de=he=!0)),t.animateAll(function(){de=he=!1,n.options.animation&&ce.forEach(function(t){T(t)}),n.options.sort&&ge()}))},dragOver:function(t){var e=t.target,n=t.completed,t=t.cancel;he&&~ce.indexOf(e)&&(n(!1),t())},revert:function(t){var n,o,e=t.fromSortable,i=t.rootEl,r=t.sortable,a=t.dragRect;1<ce.length&&(ce.forEach(function(t){r.addAnimationState({target:t,rect:he?k(t):a}),T(t),t.fromRect=a,e.removeAnimationState(t)}),he=!1,n=!this.options.removeCloneOnHide,o=i,ce.forEach(function(t,e){e=o.children[t.sortableIndex+(n?Number(e):0)];e?o.insertBefore(t,e):o.appendChild(t)}))},dragOverCompleted:function(t){var e,n=t.sortable,o=t.isOwner,i=t.insertion,r=t.activeSortable,a=t.parentEl,l=t.putSortable,t=this.options;i&&(o&&r._hideClone(),de=!1,t.animation&&1<ce.length&&(he||!o&&!r.options.sort&&!l)&&(e=k(ae,!1,!0,!0),ce.forEach(function(t){t!==ae&&(C(t,e),a.appendChild(t))}),he=!0),o||(he||ge(),1<ce.length?(o=se,r._showClone(n),r.options.animation&&!se&&o&&ue.forEach(function(t){r.addAnimationState({target:t,rect:le}),t.fromRect=le,t.thisAnimationDuration=null})):r._showClone(n)))},dragOverAnimationCapture:function(t){var e=t.dragRect,n=t.isOwner,t=t.activeSortable;ce.forEach(function(t){t.thisAnimationDuration=null}),t.options.animation&&!n&&t.multiDrag.isMultiDrag&&(le=a({},e),e=v(ae,!0),le.top-=e.f,le.left-=e.e)},dragOverAnimationComplete:function(){he&&(he=!1,ge())},drop:function(t){var e=t.originalEvent,n=t.rootEl,o=t.parentEl,i=t.sortable,r=t.dispatchSortableEvent,a=t.oldIndex,l=t.putSortable,s=l||this.sortable;if(e){var c,u,d,h=this.options,f=o.children;if(!fe)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),I(ae,h.selectedClass,!~ce.indexOf(ae)),~ce.indexOf(ae))ce.splice(ce.indexOf(ae),1),ie=null,W({sortable:i,rootEl:n,name:"deselect",targetEl:ae,originalEvent:e});else{if(ce.push(ae),W({sortable:i,rootEl:n,name:"select",targetEl:ae,originalEvent:e}),e.shiftKey&&ie&&i.el.contains(ie)){var p=B(ie),t=B(ae);if(~p&&~t&&p!==t)for(var g,m=p<t?(g=p,t):(g=t,p+1);g<m;g++)~ce.indexOf(f[g])||(I(f[g],h.selectedClass,!0),ce.push(f[g]),W({sortable:i,rootEl:n,name:"select",targetEl:f[g],originalEvent:e}))}else ie=ae;re=s}fe&&this.isMultiDrag&&(he=!1,(o[j].options.sort||o!==n)&&1<ce.length&&(c=k(ae),u=B(ae,":not(."+this.options.selectedClass+")"),!de&&h.animation&&(ae.thisAnimationDuration=null),s.captureAnimationState(),de||(h.animation&&(ae.fromRect=c,ce.forEach(function(t){var e;t.thisAnimationDuration=null,t!==ae&&(e=he?k(t):c,t.fromRect=e,s.addAnimationState({target:t,rect:e}))})),ge(),ce.forEach(function(t){f[u]?o.insertBefore(t,f[u]):o.appendChild(t),u++}),a===B(ae)&&(d=!1,ce.forEach(function(t){t.sortableIndex!==B(t)&&(d=!0)}),d&&r("update"))),ce.forEach(function(t){T(t)}),s.animateAll()),re=s),(n===o||l&&"clone"!==l.lastPutMode)&&ue.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}},nullingGlobal:function(){this.isMultiDrag=fe=!1,ue.length=0},destroyGlobal:function(){this._deselectMultiDrag(),f(document,"pointerup",this._deselectMultiDrag),f(document,"mouseup",this._deselectMultiDrag),f(document,"touchend",this._deselectMultiDrag),f(document,"keydown",this._checkKeyDown),f(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(void 0!==fe&&fe||re!==this.sortable||t&&N(t.target,this.options.draggable,this.sortable.el,!1)||t&&0!==t.button))for(;ce.length;){var e=ce[0];I(e,this.options.selectedClass,!1),ce.shift(),W({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:e,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},a(t,{pluginName:"multiDrag",utils:{select:function(t){var e=t.parentNode[j];e&&e.options.multiDrag&&!~ce.indexOf(t)&&(re&&re!==e&&(re.multiDrag._deselectMultiDrag(),re=e),I(t,e.options.selectedClass,!0),ce.push(t))},deselect:function(t){var e=t.parentNode[j],n=ce.indexOf(t);e&&e.options.multiDrag&&~n&&(I(t,e.options.selectedClass,!1),ce.splice(n,1))}},eventProperties:function(){var n=this,o=[],i=[];return ce.forEach(function(t){var e;o.push({multiDragElement:t,index:t.sortableIndex}),e=he&&t!==ae?-1:he?B(t,":not(."+n.options.selectedClass+")"):B(t),i.push({multiDragElement:t,index:e})}),{items:r(ce),clones:[].concat(ue),oldIndicies:o,newIndicies:i}},optionListeners:{multiDragKey:function(t){return"ctrl"===(t=t.toLowerCase())?t="Control":1<t.length&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}),Bt});
44,136
Common Lisp
.l
2
22,067.5
44,064
0.70128
cadrgtsecond/cl-trello
0
0
0
GPL-2.0
9/19/2024, 11:52:29 AM (Europe/Amsterdam)
638456f130bd31396968106042926bb3530a4d5411f0d69c2fb154c4bc2ff06a
44,565
[ -1 ]
44,580
package.lisp
lost-rob0t_star-cl/src/package.lisp
(in-package :cl-user) (uiop:define-package :starintel (:nicknames :spec) (:import-from :alexandria :flatten) (:use :cl) (:export #:add-inscope #:address #:address-city #:address-country #:address-postal #:address-state #:address-street #:address-street2 #:add-scope #:asn #:asn-number #:asn-subnet #:breach #:breach-description #:breach-total #:breach-url #:doc-added #:doc-dataset #:doc-eid #:doc-etype #:doc-id #:doc-sources #:doc-type #:document #:doc-updated #:domain #:domain-resolved #:email #:email-domain #:email-message #:email-message-bcc #:email-message-body #:email-message-cc #:email-message-from #:email-message-headers #:email-message-subject #:email-message-to #:email-password #:email-user #:geo #:geo-alt #:geo-lat #:geo-long #:hash-id #:host #:host-hostname #:host-ip #:host-os #:host-ports #:make-instance #:make-ulid #:message #:message-channel #:message-content #:message-group #:message-is-reply #:message-media #:message-mentions #:message-message-id #:message-platform #:message-reply-to #:message-user #:name #:network #:network-asn #:network-org #:new-address #:new-asn #:new-domain #:new-email #:new-email-with-password #:new-host #:new-message #:new-network #:new-org #:new-phone #:new-port #:new-relation #:new-social-media-post #:new-target #:new-target-without-options #:new-url #:new-user #:new-username #:org #:org-bio #:org-country #:org-name #:org-reg #:org-website #:person #:person-fname #:person-lname #:person-mname #:phone #:phone-carrier #:phone-number #:phone-status #:phone-type #:relation #:relation-note #:relation-source #:relation-target #:scope #:scope-add-to-options #:scope-description #:scope-in #:scope-out #:service #:service-port #:set-id #:set-meta #:set-type #:social-media-post-content #:social-media-post-group #:social-media-post-links #:social-media-post-media #:social-media-post-replies #:social-media-post-reply-count #:social-media-post-reply-to #:social-media-post-repost-count #:social-media-post-tags #:social-media-post-title #:social-media-post-url #:social-media-post-user #:socialmpost #:target #:target-actor #:target-dataset #:target-id #:target-options #:target-target #:timestamp #:ulid-id #:unix-now #:update-timetamp #:url #:url-content #:url-path #:url-uri #:url-url #:user #:user-bio #:user-misc #:user-name #:user-platform #:user-url #:version #:web #:web-source #:target-delay #:target-recurring-p))
2,846
Common Lisp
.lisp
158
14.075949
37
0.637277
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
c1d4c2f8b6bdb7e45434a562af6906d711198e9c66e01b0730a4bb691255f5ff
44,580
[ -1 ]
44,581
entities.lisp
lost-rob0t_star-cl/src/entities.lisp
(in-package :starintel) ;; WARNING DEVIATION FROM SPEC!!!!!!! ;; (defclass entity (document) ;; ()) (defclass person (document) ((fname :accessor person-fname :type string :initarg :fname :initform "") (mname :accessor person-mname :type string :initarg :mname :initform "") (lname :accessor person-lname :type string :initarg :lname :initform "") (bio :initarg person-bio :type string :initarg :bio :initform "") (dob :initarg person-dob :type string :initarg :dob :initform "") (race :initarg person-race :type string :initarg :race :initform "") (region :initarg person-region :type string :initarg :region :initform "") (misc :initarg person-misc :type list :initarg :misc :initform '()) ;; HACK Fix this, infact i should move the main doc to a metadata field (etype :accessor doc-etype :type string :initarg :etype :initform "person") (eid :accessor doc-eid :type string :initarg :eid :initform ""))) (defclass org (document) ((reg :accessor org-reg :type string :initarg :reg :initform "") (name :accessor org-name :type string :initarg :name :initform "") (bio :accessor org-bio :type string :initarg :bio :initform "") (country :accessor org-country :type string :initarg :country :initform "") (website :accessor org-website :type string :initarg :website :initform "") (etype :accessor doc-etype :type string :initarg :etype :initform "org") (eid :accessor doc-eid :type string :initarg :eid :initform ""))) (defmethod set-id ((doc person)) "Set the ID for a person document" (ulid-id doc)) (defmethod set-id ((doc org)) "Set the ID for an organization document" (hash-id doc (org-name doc) (org-reg doc) (org-country doc))) (defun new-org (dataset name etype &rest args) "Create a New Booker Organization" (let ((org (apply #'make-instance 'org :name name :etype etype args))) (set-meta org dataset) org)) (defun new-person (dataset fname lname etype &rest args) "Create a New Booker Person" (let ((person (apply #'make-instance 'person :fname fname :lname lname :etype etype args))) (set-meta person dataset) person))
2,127
Common Lisp
.lisp
40
49.8
93
0.704721
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
43e72417b77f558d969f41c33de52933a3c8de6ae651b4b55ecbf7dc354f6fc5
44,581
[ -1 ]
44,582
locations.lisp
lost-rob0t_star-cl/src/locations.lisp
(in-package :starintel) (defclass geo (document) ((lat :accessor geo-lat :type float64 :initarg :lat :initform 0.0) (long :accessor geo-long :type float64 :initarg :long :initform 0.0) (alt :accessor geo-alt :type float64 :initarg :alt :initform 0.0))) (defclass address (geo) ((city :accessor address-city :type string :initarg :city :initform "") (state :accessor address-state :type string :initarg :state :initform "") (postal :accessor address-postal :type string :initarg :postal :initform "") (country :accessor address-country :type string :initarg :country :initform "") (street :accessor address-street :type string :initarg :street :initform "") (street2 :accessor address-street2 :type string :initarg :street2))) (defmethod set-id ((doc geo)) (hash-id doc (geo-lat doc) (geo-long doc) (geo-alt doc))) (defmethod set-id ((doc address)) (hash-id doc (address-lat doc) (address-long doc) (address-alt doc) (address-city doc) (address-state doc) (address-postal doc) (address-country doc) (address-street doc) (address-street2 doc))) (defun new-geo (dataset &rest args) "Create a New Geo" (let ((geo (apply #'make-instance 'geo args))) (set-meta geo dataset) geo)) (defun new-address (dataset &rest args) "Create a New Booker Address" (let ((address (apply #'make-instance 'address args))) (set-meta address dataset) address))
1,527
Common Lisp
.lisp
38
34.157895
82
0.655428
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
69e0129ec6f55a15c3c4ae7b7ae16fd304ad62ad5c8debb9c6f464a2dfdc90cf
44,582
[ -1 ]
44,583
define.lisp
lost-rob0t_star-cl/src/define.lisp
(in-package :starintel) (defun create (type &rest args) (apply #'make-instance type args)) (defun -> (source target &optional note) (let* ((source-doc (apply (car source) (cdr source))) (target-doc (apply (car target) (cdr target))) (relation (make-instance 'relation :source (doc-id source-doc) :target (doc-id target-doc) :note note))) (list source-doc target-doc relation))) (defun define-docs (&rest documents) (loop for doc in documents for op = (car doc) collect (apply op (cdr doc)))) (defun read-star-file (pathname) (with-open-file (stream pathname) (let ((docs (read stream))) (flatten (apply #'define-docs docs)))))
759
Common Lisp
.lisp
19
32
63
0.607978
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
fab5ad67be25c027e87daec8d9d630f4ad5647464a0b80fb705d7f0f752b7fa6
44,583
[ -1 ]
44,584
phones.lisp
lost-rob0t_star-cl/src/phones.lisp
(in-package :starintel) (defclass phone (document) ((number :accessor phone-number :type string :initarg :number :initform "") (carrier :accessor phone-carrier :type string :initarg :carrier :initform "") (status :accessor phone-status :type string :initarg :status :initform "") (phone-type :accessor phone-type :type string :initarg :phone-type :initform ""))) (defmethod set-id ((doc phone)) (hash-id doc (phone-number doc))) (defun new-phone (dataset &rest args) "Create a Phone document" (let ((phone (apply #'make-instance 'phone args))) (set-meta phone dataset) phone))
617
Common Lisp
.lisp
14
40.214286
85
0.702838
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
57f9b4ac132ed68c2b1225e0cae98a26f6ab11275789242eaf03e0a9f37116fb
44,584
[ -1 ]
44,585
targets.lisp
lost-rob0t_star-cl/src/targets.lisp
(in-package :starintel) (defclass target (document) ((actor :accessor target-actor :type string :initarg :actor :initform "") (target :accessor target-target :type string :initarg :target :initform "") (delay :accessor target-delay :type integer :initform 0 :initarg :delay) (recurring :accessor target-recurring-p :type bool :initform nil :initarg :recurring) (options :accessor target-options :type list :initarg :options :initform nil))) (defmethod set-id ((target target)) (hash-id target (format nil "~a~a~a" (doc-dataset target) (target-target target) (target-actor target)))) (defun new-target (dataset target actor &key (options nil) (delay 0) (recurring nil)) "Create a New Booker Target" (let ((target (make-instance 'target :dataset dataset :target target :actor actor :delay delay :recurring recurring :options (or options (list))))) (set-meta target dataset) target)) (defun new-target-without-options (dataset target actor) "Create a New Booker Target Without Options" (new-target dataset target actor))
1,138
Common Lisp
.lisp
20
49.9
149
0.693141
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
1a1255df813f8654d89984cc95a4d503174b78c8d265a1229b4f0a1432188df7
44,585
[ -1 ]
44,586
web.lisp
lost-rob0t_star-cl/src/web.lisp
(in-package :starintel) (defclass breach (document) ((total :accessor breach-total :type int :initarg :total :initform 0) (description :accessor breach-description :type string :initarg :description :initform "") (url :accessor breach-url :type string :initarg :url :initform ""))) (defclass email (document) ((user :accessor email-user :type string :initarg :user :initform "") (domain :accessor email-domain :type string :initarg :domain :initform "") (password :accessor email-password :type string :initarg :password :initform ""))) (defclass email-message (document) ((body :accessor email-message-body :type string :initarg :body :initform "") (subject :accessor email-message-subject :type string :initarg :subject :initform "") (to :accessor email-message-to :type string :initarg :to :initform "") (from :accessor email-message-from :type string :initarg :from :initform "") (headers :accessor email-message-headers :type string :initarg :headers :initform "") (cc :accessor email-message-cc :type list :initarg :cc :initform '()) (bcc :accessor email-message-bcc :type list :initarg :bcc :initform '()))) (defclass user (document) ((url :accessor user-url :type string :initarg :url :initform "") (name :accessor user-name :type string :initarg :name :initform "") (platform :accessor user-platform :type string :initarg :platform :initform "") (misc :accessor user-misc :type list :initarg :misc :initform '()) (bio :accessor user-bio :type string :initarg :bio :initform ""))) (defmethod set-id ((doc email)) (hash-id doc (email-user doc) (email-domain doc) (when (> (length (email-password doc)) 0) (email-password doc)))) (defmethod set-id ((doc user)) (hash-id doc (user-name doc) (user-url doc) (user-platform doc))) (defmethod set-id ((doc email-message)) (hash-id doc (email-message-body doc) (email-message-to doc) (email-message-from doc) (email-message-subject doc))) ;; TODO make a function that takes user and domain and use that to make new-email* (defun new-email (dataset &rest args) "Create a New Booker Email" (let ((email (apply #'make-instance 'email args))) (set-meta email dataset) email)) (defun new-email* (dataset email &rest args) "Create a New Booker Email" (let* ((email-data (uiop:split-string email :max 2 :separator "@")) (user (nth 0 email-data)) (domain (nth 1 email-data)) (email (apply #'make-instance 'email :user user :domain domain args))) (set-meta email dataset) email)) (defun new-user (dataset &rest args) "Create a New Booker User" (let ((user (apply #'make-instance 'user args))) (set-id user) (set-meta user dataset) user))
2,831
Common Lisp
.lisp
59
42.711864
93
0.677677
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
6cd1ab7c9ed63d2cff11dead34abc5b6d7db96e9b547efeb21f4d872ad40bda6
44,586
[ -1 ]
44,587
relations.lisp
lost-rob0t_star-cl/src/relations.lisp
(in-package :starintel) (defclass relation (document) ((source :accessor relation-source :type string :initarg :source :initform "") (target :accessor relation-target :type string :initarg :target :initform "") (note :accessor relation-note :type string :initarg :note :initform ""))) (defmethod set-id ((doc relation)) (ulid-id doc)) (defun new-relation (dataset source target note) "Create a New Booker Relation" (let ((relation (make-instance 'relation :dataset dataset :source source :target target :note note))) (set-meta relation dataset) relation))
582
Common Lisp
.lisp
12
45.333333
103
0.736749
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
cdfd3310b6e775eb04b552d252df34a965a469413707106c79c63eadb75d7697
44,587
[ -1 ]
44,588
social-media.lisp
lost-rob0t_star-cl/src/social-media.lisp
(in-package :starintel) (defclass message (document) ((message :accessor message-content :type string :initarg :content :initform "") (platform :accessor message-platform :type string :initarg :platform :initform "") (user :accessor message-user :type string :initarg :user :initform "") (is-reply :accessor message-is-reply :type bool :initarg :is-reply :initform nil) (media :accessor message-media :type list :initarg :media :initform '()) (message-id :accessor message-id :type string :initarg :message-id :initform "") (reply-to :accessor message-reply-to :type string :initarg :reply-to :initform "") (group :accessor message-group :type string :initarg :group :initform "") (channel :accessor message-channel :type string :initarg :channel :initform "") (mentions :accessor message-mentions :type list :initarg :mentions :initform '()))) (defclass socialmpost (document) ((content :accessor social-media-post-content :type string :initarg :content :initform "") (user :accessor social-media-post-user :type string :initarg :user :initform "") (replies :accessor social-media-post-replies :type list :initarg :replies :initform '()) (media :accessor social-media-post-media :type list :initarg :media :initform '()) (reply-count :accessor social-media-post-reply-count :type int :initarg :reply-count :initform 0) (repost-count :accessor social-media-post-repost-count :type int :initarg :repost-count :initform 0) (url :accessor social-media-post-url :type string :initarg :url :initform "") (links :accessor social-media-post-links :type list :initarg :links :initform '()) (tags :accessor social-media-post-tags :type list :initarg :tags :initform '()) (title :accessor social-media-post-title :type string :initarg :title :initform "") (group :accessor social-media-post-group :type string :initarg :group :initform "") (reply-to :accessor social-media-post-reply-to :type string :initarg :reply-to :initform ""))) (defmethod set-id ((doc message)) (hash-id doc (message-content doc) (message-user doc) (message-channel doc) (message-group doc) (message-id doc) (message-platform doc))) (defmethod set-id ((doc socialmpost)) (hash-id doc (social-media-post-content doc) (social-media-post-user doc) (social-media-post-url doc) (social-media-post-group doc))) (defun new-message (dataset &rest args) "Create a New Booker Message" (let ((message (apply #'make-instance 'message args))) (set-meta message dataset) message)) (defun new-social-media-post (dataset &rest args) "Create a New Booker Social Media Post" (let ((post (apply #'make-instance 'socialmpost args))) (set-meta post dataset) post))
2,820
Common Lisp
.lisp
49
52.22449
103
0.704455
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
6d97e06c85e4d75aed580dc1f66c32f2aadce50b6da02c651082af4fc70c9689
44,588
[ -1 ]
44,589
hosts.lisp
lost-rob0t_star-cl/src/hosts.lisp
(in-package :starintel) (defclass domain (document) ((record-type :accessor domain-record-type :type string :initarg :record-type :initform "") (record :accessor domain-record :type string :initarg :record :initform "") (resolved-addresses :accessor domain-resolved :type list :initarg :resolved))) (defclass service () ((port :accessor service-port :type integer :initarg :number) (name :accessor name :type string :initarg :services) (ver :accessor version :type string :initarg :version))) (defclass network (document) ((org :accessor network-org :type string :initarg :org :initform "") (subnet :accessor network-asn :type string :initarg :subnet :initform "") (asn :accessor network-asn :type integer :initarg :asn :initform ""))) ;; TODO set empty strins (defclass host (document) ((hostname :accessor host-hostname :type string :initarg :hostname :initform "") (ip :accessor host-ip :type string :initarg :ip :initform "") (os :accessor host-os :type string :initarg :os) ;;; Should be list of <service> (ports :accessor host-ports :type list :initarg :ports))) (defclass url (document) ((url :accessor url-uri :type string :initarg :url :initform "") (path :accessor url-path :type string :initarg :path :initform "") (content :accessor url-content :type string :initarg :content))) (defmethod set-id ((doc domain)) "Set the ID for a domain document" (hash-id doc (domain-record doc) (domain-record-type doc))) (defmethod set-id ((doc network)) "Set the ID for a network document" (hash-id doc (network-asn doc) (network-org doc))) (defmethod set-id ((doc host)) "Set the ID for a host document" (hash-id doc (host-ip doc))) (defmethod set-id ((doc url)) "Set the ID for a URL document" (hash-id doc (url-url doc) (url-content doc))) (defun new-domain (dataset &rest args) "Create a New Domain" (let ((domain (apply #'make-instance 'domain args))) (set-meta domain dataset) domain)) (defun new-port (dataset &rest args) "Create a New Port" (let ((port (apply #'make-instance 'port args))) (set-meta port dataset) port)) (defun new-asn (dataset &rest args) "Create a New ASN" (let ((asn (apply #'make-instance 'asn args))) (set-meta asn dataset) asn)) (defun new-network (dataset &rest args) "Create a New Network" (let ((network (apply #'make-instance 'network args))) (set-meta network dataset) network)) (defun new-host (dataset &rest args) "Create a New Host" (let ((host (apply #'make-instance 'host args))) (set-meta host dataset) host)) (defun new-url (dataset &rest args) "Create a New URL" (let ((url (apply #'make-instance 'url args))) (set-meta url dataset) url))
2,731
Common Lisp
.lisp
66
38.121212
93
0.699623
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
3e9808609500330690596eb880b2daad488786a811aafb9a99fb319d4c8cf3bf
44,589
[ -1 ]
44,590
starintel.asd
lost-rob0t_star-cl/src/starintel.asd
(asdf:defsystem :starintel :description "Star Intel is a document Spec for handling osint data" :author "nsaspy" :license "LGLv3" :version "0.7.2" :serial t :depends-on (#:jsown #:ironclad #:local-time #:cms-ulid) :components ((:file "package") (:file "documents") (:file "entities") (:file "hosts") (:file "web") (:file "relations") (:file "targets") (:file "social-media") (:file "locations") (:file "define")))
563
Common Lisp
.asd
17
23.352941
70
0.512821
lost-rob0t/star-cl
0
0
0
LGPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
58301f83c6168ac1a079d139440aaa59a5bde6fc677f52fa5750c7b99d77392e
44,590
[ -1 ]
44,632
day3.lisp
blake-watkins_advent-of-code-2023/day3.lisp
(in-package :aoc-2023) (defun parse-indexed-number () (with-monad (assign start-rc (parse-rc-get-rc)) (assign num (lift-parser-rc (with-monad (assign digits (one-or-more (parse-digit))) (unit (digits-to-int digits :base 10))))) (assign end-rc (parse-rc-get-rc)) (unit (list :number (list start-rc end-rc) num)))) (defun parse-line () (with-monad (assign ret (one-or-more (either (parse-indexed-number) (then (parse-rc-character ".") (unit '())) (with-monad (assign sym (parse-rc-character (complement #'whitespace-char-p))) (unit (cons :symbol sym)))))) (parse-rc-newline) (unit ret))) (defun get-numbers-and-symbols (input) (let ((parsed (run-rc-parser (one-or-more (parse-line)) input))) (iter outer (for line in parsed) (iter (for (type . item) in line) (case type (:number (in outer (collect item into numbers))) (:symbol (in outer (collect item into symbols))))) (finally (return-from outer (list numbers symbols)))))) (defun number-near-symbol? (number symbol) (destructuring-bind (((sr sc) (er ec)) val) number (declare (ignore er val)) (destructuring-bind ((r c) sym) symbol (declare (ignore sym)) (and (<= (1- sc) c ec) (<= (1- sr) r (1+ sr)))))) (defun numbers-near-symbol (numbers symbol) "Return list of all numbers near to SYMBOL." (iter (for number in numbers) (when (number-near-symbol? number symbol) (collect number)))) (defun gear-ratio (numbers symbol) "Return gear ratio if SYMBOL is a gear, NIL otherwise." (when (char= #\* (second symbol)) (let ((nearby-numbers (numbers-near-symbol numbers symbol))) (when (= 2 (length nearby-numbers)) (reduce #'* nearby-numbers :key #'second))))) (defun day3 (input &key (part 1)) (destructuring-bind (numbers symbols) (get-numbers-and-symbols input) (if (= part 1) (iter (for number in numbers) (when (iter (for symbol in symbols) (thereis (number-near-symbol? number symbol))) (sum number))) (iter (for symbol in symbols) (for gear-ratio = (gear-ratio numbers symbol)) (when gear-ratio (sum gear-ratio))))))
2,171
Common Lisp
.lisp
61
31.262295
71
0.649382
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
9d0e3a53126c3bc2930064c8747b315b22b8a73f16bb38e7853bb77ac7581da1
44,632
[ -1 ]
44,633
day12.lisp
blake-watkins_advent-of-code-2023/day12.lisp
(in-package :aoc-2023) (defun parse-file () (parse-lines (with-monad (assign springs (one-or-more (either (then (parse-character #\.) (unit :works)) (then (parse-character #\#) (unit :damaged)) (then (parse-character #\?) (unit :unknown))))) (parse-whitespace) (assign condition (parse-number-list)) (unit (list springs condition))))) (defun expand-springs (springs) (rest (iter (repeat 5) (appending (cons :unknown springs))))) (defun expand-condition (condition) (iter (repeat 5) (appending condition))) (defparameter *store* (make-hash-table :test 'equal)) (defun num-valid-rec (damaged-so-far springs condition) (if (null springs) (if (or (and (zerop damaged-so-far) (null condition)) (equal (list damaged-so-far) condition)) 1 0) (case (first springs) (:damaged (num-valid (1+ damaged-so-far) (rest springs) condition)) (:works (if (plusp damaged-so-far) (if (or (null condition) (not (= damaged-so-far (first condition)))) 0 (num-valid 0 (rest springs) (rest condition))) (num-valid 0 (rest springs) condition))) (:unknown (+ (num-valid damaged-so-far (cons :damaged (rest springs)) condition) (num-valid damaged-so-far (cons :works (rest springs)) condition)))))) (defun num-valid (damaged-so-far springs condition) (let ((cached (gethash (list damaged-so-far springs condition) *store*))) (if cached cached (let ((ret (num-valid-rec damaged-so-far springs condition))) (setf (gethash (list damaged-so-far springs condition) *store*) ret) ret)))) (defun day12 (input &key (part 1)) (let ((parsed (run-parser (parse-file) input))) (iter (for (springs condition) in parsed) (when (= part 2) (setf springs (expand-springs springs)) (setf condition (expand-condition condition))) (setf *store* (make-hash-table :test 'equal)) (sum (num-valid 0 springs condition)))))
2,157
Common Lisp
.lisp
49
35.163265
82
0.596859
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
9b0338b405961226f2ccc7165f0b33b52991fba795b8e10924145ebc9873e3ce
44,633
[ -1 ]
44,634
day16.lisp
blake-watkins_advent-of-code-2023/day16.lisp
(in-package :aoc-2023) (defun parse-file () (parse-lines (one-or-more (parse-character ".#/\\|-")))) (defparameter *directions* '((:north (-1 0)) (:east (0 1)) (:south (1 0)) (:west (0 -1)))) (defun next-square (pos dir) (list (point+ pos (second (assoc dir *directions*))) dir)) (defun turn (dir c-cw) (first (elt *directions* (mod (+ (position dir *directions* :key #'first) (if (eq c-cw :cw) 1 -1)) (length *directions*))))) (defun reflect (dir pos-neg) (if (char= pos-neg #\/) (case dir (:east :north) (:north :east) (:west :south) (:south :west)) (case dir (:east :south) (:north :west) (:west :north) (:south :east)))) (defun split (dir vert-horiz) (if (char= vert-horiz #\|) (case dir ((:east :west) '(:north :south)) (t (list dir))) (case dir ((:north :south) '(:east :west)) (t (list dir))))) (defun next-positions (pos dir map) (let* ((type (gethash pos map)) (positions (case type (#\. (list (next-square pos dir))) ((#\/ #\\) (list (next-square pos (reflect dir type)))) ((#\| #\-) (mapcar (lambda (dir) (next-square pos dir)) (split dir type)))))) (remove-if-not (lambda (pos) (gethash pos map)) positions :key #'first))) (defun count-energized (start-pos start-dir map) (iter (with visited = (make-hash-table :test 'equal)) (for ((pos dir) from steps root) in-bfs-from (list start-pos start-dir) :neighbours (lambda (n) (next-positions (first n) (second n) map)) :test 'equal :single t) (setf (gethash pos visited) t) (finally (return (hash-table-count visited))))) (defun get-start-squares (dimensions) (destructuring-bind (max-r max-c) dimensions (concatenate 'list (iter (for c to max-c) (collect `((0 ,c) :south)) (collect `((,max-r ,c) :north))) (iter (for r to max-r) (collect `((,r 0) :east)) (collect `((,r ,max-c) :west)))))) (defun day16 (input &key (part 1)) (let* ((parsed (run-parser (parse-file) input)) (map (hash-table-from-list-list parsed))) (if (= part 1) (count-energized '(0 0) :east map) (iter (for (pos dir) in (get-start-squares (hash-table-dimensions map))) (maximizing (count-energized pos dir map))))))
2,327
Common Lisp
.lisp
60
33.066667
78
0.578201
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
df67218579e8f6df0ca65e4961209d4c2f7906ec4088ac74662fc663dd4c5f62
44,634
[ -1 ]
44,635
package.lisp
blake-watkins_advent-of-code-2023/package.lisp
(defpackage :advent-of-code-2023 (:nicknames :aoc-2023) (:use :cl :aoc :iterate) (:shadowing-import-from :fset :reverse :size :convert :set :set-difference :seq :subseq) (:import-from :fset :concat :empty-set :empty-map :domain-contains? :lookup :contains? :includef :arb))
283
Common Lisp
.lisp
5
53.8
105
0.714801
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
a6a08cfebc82a1c5f545efbf7b5360ffea677f23100d9ef30b81c99ff4b9d06c
44,635
[ -1 ]
44,636
day21.lisp
blake-watkins_advent-of-code-2023/day21.lisp
(in-package :aoc-2023) (defun parse-file () (parse-lines (parse-list (parse-character ".#S") ""))) (defparameter *directions* '((1 0) (-1 0) (0 1) (0 -1))) (defun get-neighbours (square map) (iter (for direction in *directions*) (for neighbour = (point+ square direction)) (for neighbour-char = (gethash neighbour map)) (when (and neighbour-char (member neighbour-char '(#\. #\S))) (collect neighbour)))) (defun day21 (input) (let* ((map (hash-table-from-list-list (run-parser (parse-file) input))) (start (iter (for (k v) in-hashtable map) (finding k such-that (char= v #\S)))) (start-squares (make-hash-table :test 'equal))) (setf (gethash start start-squares) t) (iter (repeat 64) (for squares first start-squares then next-squares) (for next-squares = (make-hash-table :test 'equal)) (iter (for (square nil) in-hashtable squares) (for neighbours = (get-neighbours square map)) (iter (for neighbour in neighbours) (setf (gethash neighbour next-squares) t))) (finally (return (hash-table-count next-squares))))))
1,180
Common Lisp
.lisp
29
34
74
0.616391
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
6fa47e966cc47074d4aa48ff4e62bc7771dc98a3fe9a15162c43e8bea330e0f5
44,636
[ -1 ]
44,637
day22.lisp
blake-watkins_advent-of-code-2023/day22.lisp
(in-package :aoc-2023) (defun vertical< (a b) (< (apply #'min (mapcar #'third a)) (apply #'min (mapcar #'third b)))) (defun xy-squares (brick) (let ((mins (mapcar #'min (first brick) (second brick))) (maxes (mapcar #'max (first brick) (second brick)))) (iter outer (for x from (first mins) to (first maxes)) (iter (for y from (second mins) to (second maxes)) (in outer (collect (list x y))))))) (defun xyz-squares (brick &optional (z-decrease 0)) (let ((mins (mapcar #'min (first brick) (second brick))) (maxes (mapcar #'max (first brick) (second brick)))) (iter outer (for x from (first mins) to (first maxes)) (iter (for y from (second mins) to (second maxes)) (iter (for z from (third mins) to (third maxes)) (in outer (collect (list x y (- z z-decrease))))))))) (defun parse-file () (parse-lines (parse-list (parse-number-list) "~"))) (defun day22 (input) (let* ((parsed (run-parser (parse-file) input)) (sorted (sort parsed #'vertical<)) (heights (make-hash-table :test 'equal)) (supports (make-hash-table :test 'equal ))) (iter (for brick in sorted) (for current-height = (iter (for square in (xy-squares brick)) (maximizing (first (gethash square heights (list 0 nil)))))) (for height-diff = (- (apply #'min (mapcar #'third brick)) current-height 1)) (iter (for square in (xy-squares brick)) (for (height supporter) = (gethash square heights nil)) (when (and height (= height current-height)) (setf (gethash supporter supports) (union (gethash supporter supports nil) (list brick) :test 'equal)))) (iter (for square in (xyz-squares brick height-diff)) (setf (gethash (list (first square) (second square)) heights) (list (third square) brick))) ;(format t "~a ~a ~%" heights supports) ) (count-disintegrate supports sorted))) (defun count-disintegrate (supports bricks) (let ((num-supports (make-hash-table :test 'equal))) (iter (for (supporter supported) in-hashtable supports) (iter (for supported-brick in supported) (incf (gethash supported-brick num-supports 0)))) (iter (for brick in bricks) (counting (or (null (gethash brick supports)) (every (lambda (s) (> (gethash s num-supports) 1)) (gethash brick supports))))) (chain-reaction bricks supports num-supports))) ;; can be disintegrated if it's not supporting anything, or if it's not the only ;; brick supporting another brick. ;; count bricks that can't get to the ground except through disintegrated brick (defun chain-reaction (bricks supports num-supports) (let ((roots (iter (for b in bricks) (unless (gethash b num-supports) (collect b))))) (iter (for brick in bricks) (collect (- (length bricks) (iter (with seen = (make-hash-table :test 'equal)) (for (pos parent steps root) in-bfs-from (remove brick roots :test 'equal) neighbours (lambda (b) (remove brick (gethash b supports) :test 'equal)) test 'equal) (setf (gethash pos seen) t) (finally (return (hash-table-count seen)))) 1)))))
3,606
Common Lisp
.lisp
85
32.647059
92
0.569152
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
cfc4c74013792ef57a94c91205731579dad6c42df58317a44aa71ed35de02b92
44,637
[ -1 ]
44,638
day13.lisp
blake-watkins_advent-of-code-2023/day13.lisp
(in-package :aoc-2023) (defun parse-file () (one-or-more (with-monad (assign ret (parse-lines (one-or-more (parse-character "#.")))) (parse-newline) (parse-newline) (unit ret)))) (defun find-vertical-reflection (map) (iter (for reflect from 1 below (length (first map))) (when (every (lambda (row) (iter (for i from 0 below (length row)) (for char-a = i) (for char-b = (+ (- reflect (/ 1 2)) (- (- reflect (/ 1 2)) char-a))) (always (or (not (<= 0 char-b (1- (length row)))) (char= (elt row char-a) (elt row char-b)))))) map) (collect reflect)))) (defun find-horizontal-reflection (map) (iter (for reflect from 1 below (length map)) (when (iter (for i from 0 below (length map)) (for row-a = i) (for row-b = (+ (- reflect (/ 1 2)) (- (- reflect (/ 1 2)) row-a))) (always (or (not (<= 0 row-b (1- (length map)))) (equal (elt map row-a) (elt map row-b))))) (collect reflect)))) (defun test-map (map) (>= (+ (length (find-horizontal-reflection map)) (length (find-vertical-reflection map))) 1)) (defun swap-char (char) (if (char= char #\#) #\. #\#)) (defun get-smudged-map (map) (iter outer (with orig-horiz = (find-horizontal-reflection map)) (with orig-vert = (find-vertical-reflection map)) (for r from 0 below (length map)) (until (iter (for c from 0 below (length (first map))) (for cur = (elt (elt map r) c)) (setf (elt (elt map r) c) (swap-char cur)) (for horiz = (set-difference (find-horizontal-reflection map) orig-horiz)) (for vert = (set-difference (find-vertical-reflection map) orig-vert)) (in outer (finding (list horiz vert) such-that (= 1 (+ (length horiz) (length vert))))) (setf (elt (elt map r) c) cur))))) (defun day13 (input) (let ((parsed (run-parser (parse-file) input))) (iter (for map in parsed) (for smudged = (get-smudged-map map)) (sum (+ (reduce #'+ (second smudged)) (* 100 (reduce #'+ (first smudged))))))))
2,284
Common Lisp
.lisp
59
30.152542
100
0.531109
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
2a22a81bb3b39c8332ebc0e860cd3644436c6cba240f738d38b74b90337c4cc3
44,638
[ -1 ]
44,639
day5.lisp
blake-watkins_advent-of-code-2023/day5.lisp
(in-package :aoc-2023) (defun parse-map () (with-monad (parse-keyword #'alphanumericp) (parse-string "-to-") (parse-keyword #'alphanumericp) (parse-string " map:") (parse-newline) (assign ranges (parse-lines (parse-list (parse-number) (parse-space)))) (parse-newline) (parse-newline) (unit ranges))) (defun parse-file () (with-monad (parse-string "seeds: ") (assign seeds (parse-number-list #\ )) (parse-newline) (parse-newline) (assign maps (parse-list (parse-map) "")) (unit (list seeds maps)))) (defun containing-range (value ranges) "Return the first range in RANGES that contains VALUE, NIL if none do." (some (lambda (range) (let ((src (second range)) (length (third range))) (when (<= src value (+ src length -1)) range))) ranges)) (defun next-range (value ranges) "Return range in RANGES with minimum starting pos at or after VALUE, or NIL. " (iter (for range in ranges) (when (>= (second range) value) (finding range minimizing (second range))))) (defun map-interval (interval ranges) "Split INTERVAL, map to new intervals based on RANGES. Returns intervals list." (destructuring-bind (start length) interval (if (= 0 length) '() (let ((containing-range (containing-range start ranges))) (if containing-range (destructuring-bind (dest src range-length) containing-range (let ((new-length (min length (- range-length (- start src))))) (cons (list (+ dest (- start src)) new-length) (map-interval (list (+ start new-length) (- length new-length)) ranges)))) (let ((next-range (next-range start ranges))) (if next-range (destructuring-bind (dest src range-length) next-range (declare (ignore dest range-length)) (let ((new-length (min length (- src start)))) (cons (list start new-length) (map-interval (list (+ start new-length) (- length new-length)) ranges)))) (list (list start length))))))))) (defun map-intervals (intervals all-ranges) (reduce (lambda (intervals ranges) (iter (for interval in intervals) (appending (map-interval interval ranges)))) all-ranges :initial-value intervals)) (defun day5 (input &key (part 1)) (destructuring-bind (seeds ranges) (run-parser (parse-file) input) (let ((intervals (if (= part 1) (mapcar (lambda (seed) `(,seed 1)) seeds) (iter (for (a b) on seeds by #'cddr) (collect (list a b)))))) (reduce #'min (map-intervals intervals ranges) :key #'first))))
2,578
Common Lisp
.lisp
71
31.408451
81
0.6492
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
6290f27a57e59dc971bed9c21f598c2ad95328620b8cb58d29b5f77d7ca148e1
44,639
[ -1 ]
44,640
day19.lisp
blake-watkins_advent-of-code-2023/day19.lisp
(in-package :aoc-2023) (defun parse-name () (parse-keyword #'alpha-char-p)) (defun parse-rule () (either (with-monad (assign part-name (parse-name)) (assign op (parse-character "><")) (assign val (parse-number)) (parse-character ":") (assign dest (parse-name)) (unit (list part-name op val dest))) (parse-name))) (defun parse-workflow () (with-monad (assign name (parse-name)) (assign rules (parse-bracketed (parse-list (parse-rule)) "{}")) (unit (cons name rules)))) (defun parse-rating () (with-monad (assign name (parse-name)) (parse-character #\=) (assign val (parse-number)) (unit (list name val)))) (defun parse-ratings () (parse-bracketed (parse-list (parse-rating)) "{}")) (defun parse-file () (with-monad (assign workflows (parse-lines (parse-workflow))) (parse-newline) (parse-newline) (assign ratings (parse-lines (parse-ratings))) (unit (list workflows ratings)))) (defun matches-rule (rule ratings) "If RATINGS match RULE return the destination workflow, otherwise NIL." (if (symbolp rule) rule (destructuring-bind (part-name op val dest) rule (let ((part-value (second (assoc part-name ratings)))) (when (funcall (case op (#\< #'<) (#\> #'>)) part-value val) dest))))) (defun destination (workflow ratings workflows) "Return whether RATINGS are accepted (:A) or rejected (:R) when starting from WORKFLOW. " (if (member workflow '(:a :r)) workflow (let* ((rules (gethash workflow workflows)) (next-destination (iter (for rule in rules) (thereis (matches-rule rule ratings))))) (destination next-destination ratings workflows)))) (defun add-part-ratings (parts) "Add each rating for each part in PARTS. " (iter (for part in parts) (summing (reduce #'+ part :key #'second)))) (defun count-ratings-combinations (ratings-ranges) "Count combinations by multiplying range size of each rating. " (reduce #'* (mapcar #'second ratings-ranges) :key #'interval-size)) (defun get-range (rule accept-reject) "Return (part-name range) list corresponding to acceptance/rejection of RULE." (destructuring-bind (part-name op val dest) rule (declare (ignore dest)) (list part-name (case op (#\< (if (eq accept-reject :accept) `(1 ,(1- val)) `(,val 4000))) (#\> (if (eq accept-reject :accept) `(,(1+ val) 4000) `(1 ,val))))))) (defun limit-ratings (limit ratings) "Intersect the rating in RATINGS by the (part-name range) LIMIT. " (destructuring-bind (limit-name limit-range) limit (iter (for rating in ratings) (for (part-name part-range) = rating) (collect (if (eq part-name limit-name) (list part-name (interval-intersect part-range limit-range)) rating))))) (defun count-accepted (workflow accepted workflows) "Get all combinations of accepted ratings starting from WORKFLOW with currently ACCEPTED ratings. " (case workflow (:a (count-ratings-combinations accepted)) (:r 0) (otherwise (iter (for rule in (gethash workflow workflows)) (if (symbolp rule) (summing (count-accepted rule accepted workflows)) (let ((accept (limit-ratings (get-range rule :accept) accepted)) (reject (limit-ratings (get-range rule :reject) accepted))) (summing (count-accepted (fourth rule) accept workflows)) (setf accepted reject))))))) (defun day19 (input &key (part 1)) (destructuring-bind (workflows ratings) (run-parser (parse-file) input) (let ((workflow-table (hash-table-from-alist workflows))) (if (= part 1) (add-part-ratings (iter (for rating in ratings) (when (eq :a (destination :in rating workflow-table)) (collect rating)))) (count-accepted :in (mapcar (lambda (n) `(,n (1 4000))) '(:x :m :a :s)) workflow-table)))))
4,185
Common Lisp
.lisp
101
33.742574
101
0.615139
blake-watkins/advent-of-code-2023
0
1
0
GPL-3.0
9/19/2024, 11:52:37 AM (Europe/Amsterdam)
4d4cac539ed337597c6cd92382632488bbd15f496c67c0c95178b1ae85077181
44,640
[ -1 ]