March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -0,0 +1,5 @@
|
|||
def fs = { fn, values -> values.collect { fn(it) } }
|
||||
def f1 = { v -> v * 2 }
|
||||
def f2 = { v -> v ** 2 }
|
||||
def fsf1 = fs.curry(f1)
|
||||
def fsf2 = fs.curry(f2)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[(0..3), (2..8).step(2)].each { seq ->
|
||||
println "fsf1$seq = ${fsf1(seq)}"
|
||||
println "fsf2$seq = ${fsf2(seq)}"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
fs f s = map f s
|
||||
f1 value = value * 2
|
||||
f2 value = value ^ 2
|
||||
fs = map
|
||||
f1 = (* 2)
|
||||
f2 = (^ 2)
|
||||
|
||||
fsf1 = fs f1
|
||||
fsf2 = fs f2
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
fs=apply;
|
||||
f1(x)=2*x;
|
||||
f2(x)=x^2;
|
||||
fsf1=any->=fs(f1,any);
|
||||
fsf2=any->=fs(f2,any);
|
||||
fsf1([0..3])
|
||||
fsf1(2([1..4])
|
||||
fsf2([0..3])
|
||||
fsf2(2([1..4])
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ txr -p "(mapcar (op mapcar (op * 2)) (list (range 0 3) (range 2 8 2)))"
|
||||
((0 2 4 6) (4 8 12 16))
|
||||
|
||||
$ txr -p "(mapcar (op mapcar (op * @1 @1)) (list (range 0 3) (range 2 8 2)))"
|
||||
((0 1 4 9) (4 16 36 64))
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
$ txr -e "(progn
|
||||
(defun fs (fun seq) (mapcar fun seq))
|
||||
(defun f1 (num) (* 2 num))
|
||||
(defun f2 (num) (* num num))
|
||||
(defvar fsf1 (op fs f1)) ;; pointless: can just be (defun fsf1 (seq) (fs f1 seq)) !!!
|
||||
(defvar fsf2 (op fs f2))
|
||||
|
||||
(print [fs fsf1 '((0 1 2 3) (2 4 6 8))]) (put-line \"\")
|
||||
(print [fs fsf2 '((0 1 2 3) (2 4 6 8))]) (put-line \"\"))"
|
||||
((0 2 4 6) (4 8 12 16))
|
||||
((0 1 4 9) (4 16 36 64))
|
||||
Loading…
Add table
Add a link
Reference in a new issue