print-table bug?

2015-02-02 Thread John Lawrence Aspden
These behave differently in 1.6 with respect to printing the empty list: (clojure.pprint/print-table (list {:a 1 :b 2 :c '()})) | :a | :b | :c | |++-| | 1 | 2 | clojure.lang.PersistentList$EmptyList@1 | (cloju

Re: much lower recursion depth with memoization

2013-09-23 Thread John Lawrence Aspden
Puzzler, thanks for all your excellent ideas! I get the impression that you're as troubled as I am by the brokenness of recursion, but it looks like it can be worked around. A bit of memory thrown at the JVM stack combined with a better memoization technique should work in most of the cases tha

Re: much lower recursion depth with memoization

2013-09-23 Thread John Lawrence Aspden
Jim, increasing the stack size solved the problem in so far as it allowed the code to run (I needed a tree depth of 2000), but then it just sat and churned for hours and ran down the battery bank on my narrowboat, so I killed it. This morning I bit the bullet and got the clojure program to outp

Re: much lower recursion depth with memoization

2013-09-23 Thread John Lawrence Aspden
C+1, James Reeves wrote: > > On 23 September 2013 00:28, John Lawrence Aspden > > > wrote: > >> Nice, but it won't work for me, since I'm trying to avoid computing all >> the values in the table, and so I can't use the pump-priming approach. I >>

Re: much lower recursion depth with memoization

2013-09-23 Thread John Lawrence Aspden
the stack size should give me as much recursion as a man could reasonably need. John. On Monday, September 23, 2013 2:13:12 PM UTC+1, Chris Perkins wrote: > > On Sunday, September 22, 2013 5:28:37 PM UTC-6, John Lawrence Aspden wrote: >> >> This recursion limit really is qu

Re: much lower recursion depth with memoization

2013-09-22 Thread John Lawrence Aspden
Ah, it turns out that adding this :jvm-opts ["-Xss50M"] to project.clj gets me about 25000 memoized self-calls, so that will do. Last time I had to worry about stack size I was programming an 8051 . I'd forgotten! Cheers, John. -- -- You received this message because you are subscribed

Re: much lower recursion depth with memoization

2013-09-22 Thread John Lawrence Aspden
ck by > running it in a bottom-up fashion a la traditional dynamic programming. > > > On Sun, Sep 22, 2013 at 8:19 AM, John Lawrence Aspden < > asp...@googlemail.com > wrote: > >> Hi Guys, >> >> I'm trying to memoize a fairly complicated double recursion

much lower recursion depth with memoization

2013-09-22 Thread John Lawrence Aspden
Hi Guys, I'm trying to memoize a fairly complicated double recursion, and it's blowing stack after not terribly many calls. I've reduced the problem to a simple test case, summing from 1 to n : user=> (clojure-version) "1.5.1" user=> (def gauss-recurse (fn [n] (if (< n 1) 0 (+ n (gauss-recurs

a bug?

2013-03-27 Thread John Lawrence Aspden
Hi, Laziness makes my head hurt. Is there any reason this is desirable behaviour?: user=> (clojure-version) "1.4.0" user=> (reduce (fn [a b] (map + [1 1] a)) [1 1] (range 1000)) (1001 1001) user=> (reduce (fn [a b] (map + [1 1] a)) [1 1] (range 1500)) StackOverflowError clojure.lang.Persiste

Re: a bit mystified by unchecked-multiply

2013-02-22 Thread John Lawrence Aspden
So, something like: (type 23) the reader makes a list of a symbol and a primitive, the evaluator evals to get a generic function and a primitive, then tries to apply the generic function to the primitive, can't find a primitive version, so boxes the primitive to an object and tries again, and t

Re: a bit mystified by unchecked-multiply

2013-02-21 Thread John Lawrence Aspden
Great, thanks! So if one is an object and one is a primitive is one of these not true? user=> (type seed1) java.lang.Long user=> (type 25214903917) java.lang.Long Cheers, John. On Wednesday, February 20, 2013 11:44:44 PM UTC, Herwig Hochleitner wrote: > > I agree that unchecked-multiply

a bit mystified by unchecked-multiply

2013-02-20 Thread John Lawrence Aspden
Hi, I'm getting an unexpected exception trying to do unchecked arithmetic: user=> (def seed1 25214903917) #'user/seed1 user=> (type seed1) java.lang.Long user=> (type 25214903917) java.lang.Long user=> (unchecked-multiply seed1 0x5DEECE66D) ArithmeticException integer overflow clojure.lang.Numbers

Re: clojure.test are macro

2013-01-28 Thread John Lawrence Aspden
Thanks Guys, I'll avoid the are macro. Any ideas why this doesn't work?: user=> (use 'clojure.test) nil user=> (use 'clojure.test.tap) nil user=> (deftest a (is true)) #'user/a user=> (run-tests) Testing user Ran 1 tests containing 1 assertions. 0 failures, 0 errors. {:type :summary, :pass 1, :

clojure.test are macro

2013-01-28 Thread John Lawrence Aspden
Hi, am I doing something wrong here?: user=> (clojure-version) "1.4.0" user=> (use 'clojure.test) nil user=> (is ((fn[x] x) 1) 1) 1 user=> (are [ x y ] (= x y) ((fn[x] x) 1) 1) StackOverflowError clojure.core/map/fn--4087 (core.clj:2426) user=> (macroexpand '(are [ x y ] (= x y) ((fn[x] x) 1) 1

Re: what should I use for my webapp?

2012-11-20 Thread John Lawrence Aspden
tfalls ahead? Off to the various tutorials. On 20/11/2012, John Gabriele wrote: > On Tuesday, November 20, 2012 8:29:19 AM UTC-5, John Lawrence Aspden wrote: > >> >> My intutition is telling me to use Python and Flask, but my heart is >> telling me to use Clojure and some frame

Re: what should I use for my webapp?

2012-11-20 Thread John Lawrence Aspden
gt; > We (a team of 3) are currently building a production stack with Datomic and > > Noir. I listed SQL and Mongo just in case :-) Feel free to ask me more here > > or off-list if you like! > > On Tuesday, November 20, 2012 3:29:19 PM UTC+2, John Lawrence Aspden wrote: >

what should I use for my webapp?

2012-11-20 Thread John Lawrence Aspden
Hi Guys, I haven't used Clojure for a year or so (I was busy in C and Verilog), but I still love it and would like to use it. I'm going to write a web app. I want to ask users to answer multiple choice questions and time their responses. I'd like them to be able to easily make accounts (the sign-

Re: recursive call boxing primitives?

2010-03-10 Thread John Lawrence Aspden
Oops, sorry, I thought my post was stuck in the moderation queue and have only just noticed the replies while browsing through the list history! Thanks to everyone who replied. Your version looks to be about six times faster than mine was. Thanks ever so much! In fact I wouldn't have noticed the d

recursive call boxing primitives?

2010-03-02 Thread John Lawrence Aspden
Hi, the other day I was at a conference in London and learned Scala. As my first program I translated a favourite fractal tree program (which I stole from: http://marblemice.com/2009/04/26/clojure-fractal-tree/). The programs are almost exactly the same in the two languages. The Scala version see