This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-18
Channels
- # atom-editor (5)
- # babashka (15)
- # beginners (80)
- # calva (11)
- # cestmeetup (6)
- # chlorine-clover (15)
- # cider (22)
- # circleci (3)
- # clojure (57)
- # clojure-europe (19)
- # clojure-italy (1)
- # clojure-nl (4)
- # clojure-spec (1)
- # clojure-switzerland (1)
- # clojure-uk (88)
- # clojurescript (92)
- # code-reviews (1)
- # cursive (6)
- # data-science (5)
- # datascript (6)
- # datomic (12)
- # events (7)
- # figwheel-main (2)
- # fulcro (55)
- # graalvm (2)
- # helix (6)
- # juxt (6)
- # kaocha (11)
- # luminus (2)
- # off-topic (82)
- # pathom (27)
- # portal (1)
- # re-frame (3)
- # reitit (25)
- # remote-jobs (8)
- # sci (11)
- # shadow-cljs (29)
- # slack-help (2)
- # spacemacs (9)
- # specter (4)
- # sql (9)
- # tree-sitter (1)
- # uncomplicate (1)
- # xtdb (26)
Hey team, noob one -- my friend and I are following along with sicp in clojure, and did an exercise to implement pascal's triangle:
(defn next-row [last-row]
(let [sum-neighbor (map-indexed
(fn [idx x]
(+ x
(get last-row
(+ 1 idx)
0)))
last-row)]
(into [1] sum-neighbor)))
(defn pascal [n]
(condp = n
0 []
1 [[1]]
(let [prev-p (pascal (- n 1))]
(conj prev-p (next-row (last prev-p))))))
Would be curious to hear if you think there's a more idiomatic clojure way to do this : }