to 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
to 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 because
)))
(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 a tree representation using vectors where the
first element is the node value and the rest are the children as suggested
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: the node value is the
first element of the vector and the children the rest of the elements.
zipper.core (loop [loc (tree-zipper [1
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
/root loc)
(recur (z/next (if (and (integer? (z/node loc)) (odd? (z/node
loc)))
(z/replace loc (* 2 (z/node loc)))
loc))
Which lets you avoid writing half the infrastructure yourself.
On Wed, Nov 27, 2013 at 6:19 AM, dabd dario
)})
loc)))
On Wed, Nov 27, 2013 at 8:35 AM, dabd dario@gmail.com javascript:
wrote:
The problem is that your vector-zip is not representing the tree I
pictured.
On Wednesday, November 27, 2013 6:26:12 AM UTC, martin_clausen wrote:
Yes, for instance like this:
(let
, 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 dario@gmail.com javascript:
wrote:
Your map-tree is exactly like an xml-zip.
The problem I find with it is that now branch? also returns true for
leaf
nodes
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
December 2013 20:27, dabd dario@gmail.com javascript: 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 a zipper (paths, parents
associated
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 dario@gmail.com javascript:wrote:
I
, James Reeves wrote:
On 4 December 2013 21:09, dabd dario@gmail.com wrote:
I didn't get there because I ran into problems with the zipper API.
When you call 'children' on a loc you get a seq of nodes instead of a seq
of locs which causes me problems in a recursive algorithm operating
.
Ultimately, to use a zipper you need to structure your algorithms to work
with a depth first traversal rather than using tree recursion. That said,
doing standard tree recursion may be the right answer. It all depends on
your use case.
On Wednesday, December 4, 2013 8:38:11 PM UTC-5, 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 for
I have a NetBeans project where my REPL shows the following path in
the classpath:
#URL file:/home/my-proj/src/clj/ , 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
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/=
On my system I have:
*clojure-version*
{:major 1, :minor 4, :incremental 0, :qualifier nil}
(java.util.Locale/getDefault)
#Locale en_US
(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-array
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, at 4:39 PM, dabd wrote:
On my system I have:
*clojure-version*
{:major 1, :minor 4, :incremental 0, :qualifier nil}
(java.util.Locale/getDefault
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(TM) SE Runtime Environment (build
AM UTC, dabd wrote:
On my system I have:
*clojure-version*
{:major 1, :minor 4, :incremental 0, :qualifier nil}
(java.util.Locale/getDefault)
#Locale en_US
(format %.1f 0.5)
0,5
(java.lang.String/format (java.util.Locale/getDefault) %.1f (to-array
[0.5]))
0.5
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 this problem
21 matches
Mail list logo