March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -0,0 +1,4 @@
|
|||
$ txr -e '(pprint (mappend (op list) "abc" "ABC" "123" (repeat "\n"))))'
|
||||
aA1
|
||||
bB2
|
||||
cC3
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
$ txr -e '(each ((x "abc") (y "ABC") (z "123")) (put-line `@x@y@z`))'
|
||||
aA1
|
||||
bB2
|
||||
cC3
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
@(do
|
||||
;; Scheme's vector-for-each: a one-liner in TXR
|
||||
;; that happily works over strings and lists.
|
||||
(defun vector-for-each (fun . vecs)
|
||||
[apply mapcar fun (range) vecs])
|
||||
|
||||
(defun display (obj : (stream *stdout*))
|
||||
(pprint obj stream))
|
||||
|
||||
(defun newline (: (stream *stdout*))
|
||||
(display #\newline stream))
|
||||
|
||||
(let ((a (vec "a" "b" "c"))
|
||||
(b (vec "A" "B" "C"))
|
||||
(c (vec 1 2 3)))
|
||||
(vector-for-each
|
||||
(lambda (current-index i1 i2 i3)
|
||||
(display i1)
|
||||
(display i2)
|
||||
(display i3)
|
||||
(newline))
|
||||
a b c)))
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
@(do
|
||||
(macro-time
|
||||
(defun question-var-to-meta-num (var)
|
||||
^(sys:var ,(int-str (cdr (symbol-name var))))))
|
||||
|
||||
(defmacro map (square-fun . square-args)
|
||||
(tree-bind [(fun . args)] square-fun
|
||||
^[apply mapcar (op ,fun ,*[mapcar question-var-to-meta-num args])
|
||||
(macrolet ([(. args) ^(quote ,args)])
|
||||
(list ,*square-args))]))
|
||||
|
||||
(defun word (. items)
|
||||
[apply format nil "~a~a~a" items])
|
||||
|
||||
(defun show (x) (pprinl x))
|
||||
|
||||
(show (map [(word ?1 ?2 ?3)] [a b c] [A B C] [1 2 3])))
|
||||
Loading…
Add table
Add a link
Reference in a new issue