Added folder batch example

This commit is contained in:
Devine Lu Linvega
2019-07-27 19:36:03 +09:00
parent 26f77727f3
commit af4d294d2c
5 changed files with 51 additions and 20 deletions

View 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)

View File

@@ -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

View File

@@ -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)
)
)