Re: Using a function in another function

2016-11-10 Thread Max Countryman
The issue is (add1 (add1 [x])) is malformed: you probably mean (add1 (add1 x)). An addn function could be implemented with iterate: (defn addn [n x] (nth (iterate add1 x) n)) > On Nov 10, 2016, at 06:51, 'Rickesh Bedia' via Clojure > wrote: > > I have this function: > (defn add1 [x] >

Re: Using a function in another function

2016-11-10 Thread Colin Yates
Your inner (add1 [x]) is calling add1 with a vector containing x, you want (add1 x): (defn add2 [x] (add1 (add1 x)) HTH On 10 November 2016 at 14:51, 'Rickesh Bedia' via Clojure wrote: > I have this function: > (defn add1 [x] > (+ 1 x)) > which is just a very simple function that adds 1

Using a function in another function

2016-11-10 Thread 'Rickesh Bedia' via Clojure
I have this function: (defn add1 [x] (+ 1 x)) which is just a very simple function that adds 1. I now want to create a new function called add2 that uses add1 twice. I have tried (defn add2 [x] (add1 (add1 [x])) but this doesn't work. (Can someone explain why this doesn't work. I think it