Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Brace-expansion/PicoLisp/brace-expansion-1.l
Normal file
32
Task/Brace-expansion/PicoLisp/brace-expansion-1.l
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
(de braceExpand (Str)
|
||||
(let Lst
|
||||
(make
|
||||
(for (Lst (chop Str) Lst)
|
||||
(case (pop 'Lst)
|
||||
("\\" (link (pop 'Lst)))
|
||||
("{"
|
||||
(recur ()
|
||||
(let L
|
||||
(make
|
||||
(while
|
||||
(case (pop 'Lst)
|
||||
("\\" (link (pop 'Lst)) Lst)
|
||||
("{" (recurse) Lst)
|
||||
("}" NIL)
|
||||
("," (link 0) Lst) # Replace commata with '0'
|
||||
(T (link @) Lst) ) ) )
|
||||
(if (= "}" @) # Was closing brace
|
||||
(if (member 0 L) # Has comma(ta)
|
||||
(link (split L 0))
|
||||
(chain (list "{") (replace L 0 ",") (list "}")))
|
||||
(chain (list "{") (replace L 0 ",")) ) ) ) )
|
||||
(T (link @)) ) ) )
|
||||
(recur (Lst)
|
||||
(ifn (find pair Lst)
|
||||
(list (pack Lst))
|
||||
(let R (recurse (cdr Lst))
|
||||
(mapcan
|
||||
'((A) (mapcar '((B) (pack A B)) R))
|
||||
(if (pair (car Lst))
|
||||
(mapcan recurse (car Lst))
|
||||
(list (car Lst)) ) ) ) ) ) ) )
|
||||
33
Task/Brace-expansion/PicoLisp/brace-expansion-2.l
Normal file
33
Task/Brace-expansion/PicoLisp/brace-expansion-2.l
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
(test
|
||||
(quote
|
||||
"~/Downloads/*.jpg"
|
||||
"~/Downloads/*.gif"
|
||||
"~/Downloads/*.png"
|
||||
"~/Pictures/*.jpg"
|
||||
"~/Pictures/*.gif"
|
||||
"~/Pictures/*.png" )
|
||||
(braceExpand "~/{Downloads,Pictures}/*.{jpg,gif,png}") )
|
||||
|
||||
(test
|
||||
(quote
|
||||
"Itemized, please."
|
||||
"Itemize, please."
|
||||
"Italicized, please."
|
||||
"Italicize, please."
|
||||
"Iterated, please."
|
||||
"Iterate, please." )
|
||||
(braceExpand "It{{em,alic}iz,erat}e{d,}, please.") )
|
||||
|
||||
(test
|
||||
(quote
|
||||
"cowbell!"
|
||||
"more cowbell!"
|
||||
"gotta have more cowbell!"
|
||||
"gotta have\, again\, more cowbell!" )
|
||||
(braceExpand "{,{,gotta have{ ,\\, again\\, }}more }cowbell!") )
|
||||
|
||||
(test
|
||||
(quote
|
||||
"{}} some }{,{\\ edge \,}{ cases, {here} \\\\\}"
|
||||
"{}} some }{,{\\ edge \,}{ cases, {here} \\\\\}" )
|
||||
(braceExpand "{}} some }{,{\\\\{ edge, edge} \\,}{ cases, {here} \\\\\\\\\\}") )
|
||||
Loading…
Add table
Add a link
Reference in a new issue