Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functional-programming chapter; improve examples and explain iterate #8

Open
timothypratley opened this issue Jul 25, 2018 · 0 comments

Comments

@timothypratley
Copy link
Owner

your exercises for functional-programming chapter rely heavily on iterate, but that's not brought up in the chapter. Exercise for the author: how do you solve those problems without iterate? (Doable, in theory.) More seriously, it might be better to defer those exercises in favor of something more related to map, reduce, and/or filter.

Also, maybe have an exercise to just rewrite an existing super nested expression using a threading macro, since the topic was covered? Ex, when already given:

(defn count-i-before-e
  [s]
  (count (filter #(= % [\i \e]) (partition 2 1 (seq s)))))

Try: (count-i-before-e "sieve") and (count-i-before-e "seize") Now rewrite using thread-last macro (->>):

(defn count-i-before-e
  [s]
  (->> s
       seq
       (partition 2 1)
       (filter #(= % [\i \e]))
       count))

I think some work can go into exercises for map/reduce/filter to replace the ones using iterate, what do you think? I would need some time to think on what to come up with ideas for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant