Working clojure zippers and trees

2013-11-26 Thread dabd
change a simple tree. I'd like to multiply the odd numbers by 2 in this case. https://gist.github.com/dabd/7666778 It looks like after editing the first (branch) node clojure.zip/next will get to the end of the tree. How can I correct this code? Thanks. -- -- You received this me

Working with zippers and trees

2013-11-26 Thread dabd
change a simple tree. I'd like to multiply the odd numbers by 2 in this case. https://gist.github.com/dabd/7666778 It looks like after editing the first (branch) node clojure.zip/next will get to the end of the tree. How can I correct this code? Thanks. -- -- You received this message be

Re: Working with zippers and trees

2013-11-26 Thread dabd
(recur (next (if (and (integer? (node loc)) (odd? (node loc))) >(replace loc (* 2 (node loc))) >loc)) > > > [2 2 [6 4 10]] > > On Tuesday, November 26, 2013 10:50:34 PM UTC+1, dabd wrote: >> >> I am trying to work with

Re: Working with zippers and trees

2013-11-26 Thread dabd
r > your specific use-case? > > > On Wednesday, November 27, 2013 2:59:40 AM UTC+1, dabd wrote: >> >> The built-in vector-zip will build a tree with a different structure than >> what I need. >> I want build a tree as described in the first post:

Re: Working with zippers and trees

2013-11-26 Thread dabd
Thanks. Do you think the call to z/edit in my code could be simplified? To edit a branch node I have to use conj to build a node only to pass it to make-node which will break it apart again. On Wednesday, November 27, 2013 5:53:31 AM UTC, Carlo wrote: > > Okay, now after actually reading the doc

Re: Working with zippers and trees

2013-11-26 Thread dabd
f. > > On Wed, Nov 27, 2013 at 6:19 AM, dabd > > wrote: > > I'm not sure what you mean by not being able to provide a meaningful > > branch?. > > > > I would like to represent a tree such a this: > > > >

Re: Working with zippers and trees

2013-11-27 Thread dabd
(z/replace loc {:v(* 2 (:v (z/node loc))) :cs > (z/children loc)}) >loc))) > > On Wed, Nov 27, 2013 at 8:35 AM, dabd > > wrote: > > The problem is that your vector-zip is not representing the tree I > pictured. > > >

Re: Working with zippers and trees

2013-11-27 Thread dabd
ct leaf nodes, that kan be done by checking for > the presence of a non-empty value of the children key. > > On Wed, Nov 27, 2013 at 2:18 PM, dabd > > wrote: > > Your map-tree is exactly like an xml-zip. > > The problem I find with it is that now branch? also returns

Advice on choosing the right data structure

2013-12-04 Thread dabd
I would like to implement an algorithm that works on trees (n-ary trees) where each node is a complex type. Aside from the usual tree traversals I will need to be able to access the parent of a node. Performance is important since the algorithm is going to traverse the tree several times and upd

Re: Advice on choosing the right data structure

2013-12-04 Thread dabd
wrote: > > On 4 December 2013 20:27, dabd > wrote: > >> >> I tried a purely functional approach with zippers but ran into some >> trouble with the zipper API. I also think I will would have performance >> problems too as there is a lot of bookkeeping in

Re: Advice on choosing the right data structure

2013-12-04 Thread dabd
rs for your trees, without > using clojure.zip. I've done this for navigating into json structures and > it was relatively painless (admittedly I only needed a smallish subset of > the functionality provided by clojure.zip). > > > On Wed, Dec 4, 2013 at 1:09 PM, dabd &g

Re: Advice on choosing the right data structure

2013-12-04 Thread dabd
see if you actually have performance problems first. > > On Wednesday, December 4, 2013 5:30:02 PM UTC-5, James Reeves wrote: >> >> On 4 December 2013 21:09, dabd wrote: >> >>> I didn't get there because I ran into problems with the zipper API. >>> W

Re: Advice on choosing the right data structure

2013-12-07 Thread dabd
gt; > On Wednesday, December 4, 2013 8:38:11 PM UTC-5, dabd wrote: >> >> Thanks I'll take a look at your libraries. >> One problem I found with the zipper API is that if you have a recursive >> function that takes a loc, when you call it on the clojure.zip/childre

weird repl behavior

2014-02-25 Thread dabd
I am using the latest CIDER 0.6.0alpha (package: 20140224.735) (Clojure 1.5.1, nREPL 0.2.1) on Windows. I noticed suddenly my repl started to miss some println messages in my code. A simple test like this shows: > (do (println "hello") (println "there")) hello It won't print the second message f

Macro with odd behavior

2013-01-26 Thread dabd
I defined this macro https://gist.github.com/4646206 that expands to a function. It behaves like this mycode.core> ((interval-test-fn "9.0,9.7-10.8,19.1+") 19.1) false mycode.core> (macroexpand-1 '(interval-test-fn "9.0,9.7-10.8,19.1+")) (clojure.core/fn [v8568] (clojure.core/or (clojure.core/<

clojure.core/format localization problems

2013-03-09 Thread dabd
On my system I have: > *clojure-version* {:major 1, :minor 4, :incremental 0, :qualifier nil} > (java.util.Locale/getDefault) # > (format "%.1f" 0.5) "0,5" > (java.lang.String/format (java.util.Locale/getDefault) "%.1f" (to-array [0.5])) "0.5" but > (java.lang.String/format "%.1f" (to-arr

Re: clojure.core/format localization problems

2013-03-09 Thread dabd
ult > locale was also en_US on all of these systems. > > Mac OS X 10.6.8 + java version 1.6.0_43 (Oracle/Apple) > Ubuntu 11.10 with Linux kernel 3.0.0-31-generic + java version 1.6.0_27 > (OpenJDK) > Windows 7 + java version 1.7.0_07 (Oracle) > > Andy > > On Mar 9, 2013,

Re: clojure.core/format localization problems

2013-03-09 Thread dabd
I installed the latest 1.7.0_17 and apparently the issue is gone but I still don't know what caused it. Thanks. On Sunday, March 10, 2013 3:22:21 AM UTC, dabd wrote: > > I am trying to run clojure on windows 7 with this java version: > java version "1.7.0_05" > Java

Re: clojure.core/format localization problems

2013-03-17 Thread dabd
, 2013 12:39:57 AM UTC, dabd wrote: > > On my system I have: > > > *clojure-version* > {:major 1, :minor 4, :incremental 0, :qualifier nil} > > > (java.util.Locale/getDefault) > # > > > > (format "%.1f" 0.5) > "0,5" > > >

Re: clojure.core/format localization problems

2013-03-17 Thread dabd
It seems like 1.7 changed how default Locales are read from the host: http://stackoverflow.com/questions/7107972/java-7-default-locale http://blog.ej-technologies.com/2011/12/default-locale-changes-in-java-7.html On Sunday, March 17, 2013 10:40:19 PM UTC, dabd wrote: > > I'm having t

classpath problem while invoking Clojure from Java?

2010-02-26 Thread dabd
I have a NetBeans project where my REPL shows the following path in the classpath: # , and I can execute a script with clojure.lang.RT.loadResourceScript("foo/bar/baz.clj"), which is located in /home/my-proj/src/clj/foo/bar/baz.clj with no problems. On another project which is the same as the pre