var args with recur

2015-01-20 Thread Hello Funk
This stumped a few of us on #clojure, with a debate as to whether this is a compiler error or has a legitimate explanation. My initial examination: https://www.refheap.com/96295 A more minimal example: https://www.refheap.com/96296 What's going on? Andrew -- You received this message

Re: var args with recur

2015-01-20 Thread Francis Avila
The difference is how rest args are handled. From the recur documentation: In particular, if the recursion point was the top of a variadic fn method, there is no gathering of rest args - a single seq (or null) should be passed. So your two calls are not the same. f1 calls (recur x some-seq)

var args

2010-09-14 Thread Michael Ossareh
Hi, I don't fully understand how to make real use of varargs and destructuring. c.c.sql/create-table is defined as follows: (create-table name specs) Called as follows: (c.c.sql/create-table :tblname [:cola :text NOT NULL PRIMARY KEY] [:colb :number NOT NULL] [:colc :blob NOT NULL)] I

Re: var args

2010-09-14 Thread CuppoJava
Hi mike, Your problem is about to calling a function with a list of arguments, which is independent of varargs. Take a look at the apply function. It does what you're looking for. Cheers -Patrick On Sep 14, 2:47 am, Michael Ossareh ossa...@gmail.com wrote: Hi, I don't fully understand how to

Re: var args

2010-09-14 Thread Alan
First, you could use destructuring to make your map function cleaner. The following is exactly identical to your definition. It declares that it will be passed one argument; because that argument is [...], it will be a seq; it asks that the seq be split into y, the first element, and z, a seq of

Re: var args

2010-09-14 Thread Michael Ossareh
Alan and Patrick, thank you so much! I've come across apply in JS and it really should have clicked for me! So I have the following, and it works very well: (defn make-tables [connection schema] (sql/with-connection connection (doseq [[name specs] schema] (try

Re: var args

2010-09-14 Thread Alan
Great. Looks shiny and idiomatic to me. On Sep 14, 12:06 pm, Michael Ossareh ossa...@gmail.com wrote: Alan and Patrick, thank you so much! I've come across apply in JS and it really should have clicked for me! So I have the following, and it works very well: (defn make-tables   [connection

Re: var args

2010-09-14 Thread Meikel Brandmeyer
Hi, Am 14.09.2010 um 23:01 schrieb Alan: (defn make-tables [connection schema] (sql/with-connection connection (doseq [[name specs] schema] (try (apply sql/create-table name specs) (catch Exception e (prn e)) You actually don't