Hello,
I'm trying to come up with a way to recreate a directory hierarchy. Entries
within zip archives are just flat strings like top/level/file1, but I
would like to operate on them hierarchically. So my problem could be stated
as:
If
(restore-hierarchy [[top level file1] [top level
My observation is best distilled with the following definition of a
function in Clojure 1.2:
user= (defn id [x] (list id x))
#'user/id
Interstingly, (id 7) and (eval (id 7)) result in different instances
of function id as the number after the '@' char unveils:
user= (id 7)
(#user$id
How about extending java.sql.ResultSet to implement
clojure.lang.Seqable instead? Now that we have this capability
wouldn't it be ideal to not have any more foo*-seq functions?
Since a ResultSet is also a resource that needs to be closed in a
timely manner it might be clearer to follow the
This is my take on this: http://gist.github.com/957028
The second file produces the correct result. The result isn't exactly like
you asked for. This is because it wouldn't support files that isn't in the
lowest level.
Ex:
(restore-hierarchy [[top level file1] [top level file2] [top
level2
(defn add-path [h path]
(let [dir (butlast path)
entry (last path)]
(update-in h dir (fn [x] (if x (conj x entry) [entry])
(defn restore-hierarchy [paths]
(reduce add-path {} paths))
Then
(restore-hierarchy [[top level file1] [top level file2]
[top level2 file3]])
= {top
= uses the clojure.lang.Util/equiv to compare two things. The source of
this function is: [1]
static public boolean equiv(Object k1, Object k2){
if(k1 == k2)
return true;
if(k1 != null)
{
if(k1 instanceof Number k2 instanceof
In 1.3 the function will (eval) to itself:
Clojure 1.3.0-alpha6
user= (defn id [x] (list id x))
#'user/id
user= (id 7)
(#user$id user$id@3411a 7)
user= (eval (id 7))
(#user$id user$id@3411a 7)
user= (= (id 7) (eval (id 7)))
true
On May 5, 6:04 am, Dominikus dominikus.herzb...@gmail.com wrote:
Beautiful solution, I got a lot out of it.
Thanks Juha!
--
Ambrose
On Thu, May 5, 2011 at 10:08 PM, Juha Arpiainen jarpi...@gmail.com wrote:
(defn add-path [h path]
(let [dir (butlast path)
entry (last path)]
(update-in h dir (fn [x] (if x (conj x entry) [entry])
(defn
Am Donnerstag, 5. Mai 2011 16:06:52 UTC+2 schrieb odyssomay:
This is my take on this: http://gist.github.com/957028
The second file produces the correct result. The result isn't exactly like
you asked for. This is because it wouldn't support files that isn't in the
lowest level.
Your are
On Thu, May 05, 2011 at 05:40:02AM -0700, Steffen wrote:
Hello,
I'm trying to come up with a way to recreate a directory hierarchy. Entries
within zip archives are just flat strings like top/level/file1, but I would
like to operate on them hierarchically. So my problem could be stated as:
Thanks a lot, Armando. Looks like I should switch to Clojure 1.3 asap.
Cheers,
Dominikus
2011/5/5 Armando Blancas armando_blan...@yahoo.com:
In 1.3 the function will (eval) to itself:
Clojure 1.3.0-alpha6
user= (defn id [x] (list id x))
#'user/id
user= (id 7)
(#user$id user$id@3411a 7)
Thanks for the pointers to the implementation, Jonathan!
Unfortunately, I couldnt' find out yet, which part of the source code
in Clojure 1.3 is responsible for fixing the misbehavior in 1.2. The
parts you point to haven't changed in 1.3.
Cheers,
Dominikus
On May 5, 4:27 pm, Jonathan Fischer
I'm also interested in that.
I think it has to do with how clojure.lang.Compiler [1] works (since that is
what eval uses),
but since it is quite big, I don't know exactly what parts are important.
Jonathan
[1]
https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/Compiler.java
It also seems that I have been linking to the wrong repo... :S
https://github.com/clojure/clojure
Should be the correct one.
On Thu, May 5, 2011 at 6:09 PM, Jonathan Fischer Friberg
odysso...@gmail.com wrote:
I'm also interested in that.
I think it has to do with how clojure.lang.Compiler [1]
Hi,
It is a pleasure to announce the release of Jark 0.3, today.
Why Jark?
Startup time of the Java Virtual Machine(JVM) is too slow and thereby
command-line applications on the JVM are sluggish and very painful to
use.
Jark is an attempt to run a persistent JVM daemon and provide a set of
Hi
How do I get latest clojure and clojure-contrib? I understand now
there is no a single contrib lib, but if you go to
http://dev.clojure.org/display/design/Contrib+Projects and click on
xml project you'll an empty git project.
I tried to use clojre + contrib 1.2 but it lacks support for
Not all of the new contrib libs have been released yet. For the ones that
have been released, you can find the .jar files here:
http://repo2.maven.org/maven2/org/clojure/
-Stuart S
clojure.com
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post
This is another case of function-object evaluation acting hinky, actually.
Specifically, (eval (id 7)) is evaluating a list of (id 7), not ('id
7). As near as I can figure out, rather than embed the function object
reference into the code OR complain, it is creating a new instance of
its class
(let [fnmaker4 (fn [coll] (fn [n] (nth coll n)))
ints (range)]
(= (fnmaker4 ints) (fnmaker4 ints)))
You want to make it impossible to compare functions that close over
infinite sequences? What is the point of being able to compare
functions if there are cases in which using the functions
On Wed, May 4, 2011 at 8:01 PM, Ken Wesson kwess...@gmail.com wrote:
Note that instantiating the class with 4 gives us an add-4-to function
instead of the original add-3-to function here. To actually convert
that particular closure into code that reproduces it, the array of
constructor
On Thu, May 5, 2011 at 4:16 PM, Alan a...@malloys.org wrote:
(let [fnmaker4 (fn [coll] (fn [n] (nth coll n)))
ints (range)]
(= (fnmaker4 ints) (fnmaker4 ints)))
You want to make it impossible to compare functions that close over
infinite sequences? What is the point of being able to
On May 5, 1:28 pm, Ken Wesson kwess...@gmail.com wrote:
On Thu, May 5, 2011 at 4:16 PM, Alan a...@malloys.org wrote:
(let [fnmaker4 (fn [coll] (fn [n] (nth coll n)))
ints (range)]
(= (fnmaker4 ints) (fnmaker4 ints)))
You want to make it impossible to compare functions that close
I created a new datatype to solve this problem:
http://gist.github.com/958001
c-fn creates a comparable function;
(let [fnmaker4 (fn [coll] (c-fn [n] (nth coll n)))
ints (range)]
(= (fnmaker4 ints) (fnmaker4 ints)))
= true
On Thu, May 5, 2011 at 10:41 PM, Alan a...@malloys.org wrote:
Although (as I just realized), it fails miserably with closures.
On Thu, May 5, 2011 at 11:38 PM, Jonathan Fischer Friberg
odysso...@gmail.com wrote:
I created a new datatype to solve this problem:
http://gist.github.com/958001
c-fn creates a comparable function;
(let [fnmaker4 (fn [coll]
On Thu, May 5, 2011 at 4:41 PM, Alan a...@malloys.org wrote:
Right. But if I drop all references to the returned function after I'm
done with it, it gets GCed. If there's some class holding a reference
to it forever, it will never get cleaned up. For example, ((fnmaker4
(range)) 1e6) will (I
On Thu, May 5, 2011 at 10:18 AM, Trastabuga lisper...@gmail.com wrote:
How do I get latest clojure and clojure-contrib?
It depends on how bleeding edge you want to be.
If you want to try the most recent monolithic contrib build, you could
depend on these:
[org.clojure/clojure 1.3.0-alpha4]
26 matches
Mail list logo