Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Same-fringe/Clojure/same-fringe-1.clj
Normal file
9
Task/Same-fringe/Clojure/same-fringe-1.clj
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(defn fringe-seq [branch? children content tree]
|
||||
(letfn [(walk [node]
|
||||
(lazy-seq
|
||||
(if (branch? node)
|
||||
(if (empty? (children node))
|
||||
(list (content node))
|
||||
(mapcat walk (children node)))
|
||||
(list node))))]
|
||||
(walk tree)))
|
||||
3
Task/Same-fringe/Clojure/same-fringe-2.clj
Normal file
3
Task/Same-fringe/Clojure/same-fringe-2.clj
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(defn vfringe-seq [v] (fringe-seq vector? #(remove nil? (rest %)) first v))
|
||||
(println (vfringe-seq [10 1 2])) ; (1 2)
|
||||
(println (vfringe-seq [10 [1 nil nil] [20 2 nil]])) ; (1 2)
|
||||
6
Task/Same-fringe/Clojure/same-fringe-3.clj
Normal file
6
Task/Same-fringe/Clojure/same-fringe-3.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(defn seq= [s1 s2]
|
||||
(cond
|
||||
(and (empty? s1) (empty? s2)) true
|
||||
(not= (empty? s1) (empty? s2)) false
|
||||
(= (first s1) (first s2)) (recur (rest s1) (rest s2))
|
||||
:else false))
|
||||
Loading…
Add table
Add a link
Reference in a new issue