Added folder batch example
This commit is contained in:
24
examples/batch/folder.lisp
Normal file
24
examples/batch/folder.lisp
Normal file
@@ -0,0 +1,24 @@
|
||||
; open every file in a folder.
|
||||
(defn filter-jpg
|
||||
(file-name)
|
||||
(eq
|
||||
(last
|
||||
(split file-name ".")) "jpg"))
|
||||
;
|
||||
(def images
|
||||
(filter
|
||||
(dir) filter-jpg))
|
||||
;
|
||||
(debug
|
||||
(concat "Found: "
|
||||
(len images)))
|
||||
;
|
||||
(defn image-operation
|
||||
(file-name)
|
||||
(
|
||||
(def file-path
|
||||
(concat
|
||||
(dirpath) "/" file-name))
|
||||
(open file-path)))
|
||||
;
|
||||
(each images image-operation)
|
||||
@@ -35,9 +35,9 @@
|
||||
(test "range simple" (range 0 4) (0 1 2 3 4))
|
||||
(test "range with step" (range 0 4 2) (0 2 4))
|
||||
(test "range with negative step" (range 0 -4 -1) (0 -1 -2 -3 -4))
|
||||
(test "map" (map (λ (a) (add 1 a)) (1 2 3)) (2 3 4))
|
||||
(test "filter" (filter (λ (a) (eq 0 (mod a 2))) (2 3 4 5 6)) (2 4 6))
|
||||
(test "reduce" (reduce (λ (acc val) (add acc val)) (1 2 3) 4) 10)
|
||||
(test "map" (map (1 2 3) (λ (a) (add 1 a))) (2 3 4))
|
||||
(test "filter" (filter (2 3 4 5 6)) (λ (a) (eq 0 (mod a 2))) (2 4 6))
|
||||
(test "reduce" (reduce (1 2 3) (λ (acc val) (add acc val)) 4) 10)
|
||||
|
||||
; Scope
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
(defn dejong (r a b c d)
|
||||
(reduce
|
||||
(range 0 r)
|
||||
(λ (acc val)
|
||||
(first (
|
||||
(_dejong (first acc) (last acc) a b c d)
|
||||
)))
|
||||
(range 0 r)
|
||||
(2 1)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user