Idiomatic clojure for decorating graph

2011-11-11 Thread Colin Yates
Hi all, What is the idiomatic way to decorate a nested graph with multiple decorators? Let me explain: I have a list of graphs: [ { :id 1 propertyA: {:customer 1 :name whatever :date (Date.)} propertyB: {:customer 1 :created (Date.) :someOtherProperty 13} } ] After creating this graph

Re: Idiomatic clojure for decorating graph

2011-11-11 Thread Colin Yates
Oops - clicked wrong button (why doesn't gmail have paredit!) - sorry... (defn transform [graphs] (let [ ;; map of {:id customer} customers (load-customers-by-id graphs) ] (defn resolve-customer [g] (assoc g :customer ((:customer g) customers (defn

Re: gaidica command??

2011-11-11 Thread Joost
On Nov 11, 5:29 am, jayvandal s...@ida.net wrote: I tried this command but can't find how to execute it.  $ lein run -m gaidica.core What folder do I execute this ? (Vista windows ) Probably simple but  it's difficult for me Thanks # gaidica Example Seesaw application. Display weather

Re: Debugging lazy seqs with log4j

2011-11-11 Thread Sean Corfield
Have you tried clojure.tools.logging to see whether you get the same behavior? On Fri, Nov 11, 2011 at 8:15 AM, finbeu info_pe...@t-online.de wrote: Hello, I'm using log4j and have some a simple wrappers in clojure that work well so far. Actually, I do (def *logger* (Logger/getRootLogger))

Re: Debugging lazy seqs with log4j

2011-11-11 Thread Meikel Brandmeyer (kotarak)
Hi, what happens is probable that the logger tries to turn the lazy seq object itself into a string. Try calling pr-str on the seq before passing it to debug: (debug (pr-str your-seq-object)). Sincerely Meikel -- You received this message because you are subscribed to the Google Groups

Re: Debugging lazy seqs with log4j

2011-11-11 Thread finbeu
Hi Sean no, not yet. I stick with my own simple logging ns which works nice so far. Just have to fix this ...) (but I use clojure.java.jdbc with Sybase ASE 15.0.3. I hope I will find some time soon to contribute some testcases.) Finn -- You received this message because you are subscribed

Re: Debugging lazy seqs with log4j

2011-11-11 Thread finbeu
Yes! That's it. With pr-str it works. Thx!! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To

Re: Debugging lazy seqs with log4j

2011-11-11 Thread Sean Corfield
On Fri, Nov 11, 2011 at 8:53 AM, finbeu info_pe...@t-online.de wrote: no, not yet. I stick with my own simple logging ns which works nice so far. Just have to fix this ...) I just wondered whether using a well-maintained standard library might be an easier path than rolling your own... (but I

Re: Debugging lazy seqs with log4j

2011-11-11 Thread finbeu
yes, when starting my project, I was looking at the logging library which resides (resided) in clojure.contrib and I didn't like it at that point in time. I think because it was trying to do too many things at once. If my use case can be solved with some small java wrappers, I try to do it on

Re: gaidica command??

2011-11-11 Thread sixs
This is what I get when I run the commands. I have had lleiningen installed and used it somewhat. I get the classpath error and I don't understand ? Thanks for your help Microsoft Windows [Version 6.0.6000] Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\Users\jim.jim-PCcd\

Re: Debugging lazy seqs with log4j

2011-11-11 Thread Sean Corfield
On Fri, Nov 11, 2011 at 9:25 AM, finbeu info_pe...@t-online.de wrote: yes, when starting my project, I was looking at the logging library which resides (resided) in clojure.contrib and I didn't like it at that point in time. I think because it was trying to do too many things at once. If my use

Re: Debugging lazy seqs with log4j

2011-11-11 Thread finbeu
Thanks. I think when I tried it (correct me if I'm wrong) it was not possible to set the debug level dynamic. For instance I usually have a port where I can send messages to (simple UDP datagram packet), the message string is a map which I read-string and eval and upon that event, I reset some

Re: Debugging lazy seqs with log4j

2011-11-11 Thread Alex Baranosky
You could consider contributing your improvements to the logging library. On Nov 11, 2011 10:27 AM, finbeu info_pe...@t-online.de wrote: Thanks. I think when I tried it (correct me if I'm wrong) it was not possible to set the debug level dynamic. For instance I usually have a port where I can

Re: Idiomatic clojure for decorating graph

2011-11-11 Thread Brian Marick
On Nov 11, 2011, at 4:48 AM, Colin Yates wrote: Now this works except for the fact I have multiple decorators which work on a graph which might be 5 levels deep and looks horrible :). Have you looked into clojure.zip?

Re: Idiomatic clojure for decorating graph

2011-11-11 Thread Colin Yates
Thanks Brian - I will look into it. On 11 November 2011 15:40, Brian Marick mar...@exampler.com wrote: On Nov 11, 2011, at 4:48 AM, Colin Yates wrote: Now this works except for the fact I have multiple decorators which work on a graph which might be 5 levels deep and looks horrible :).

How do I store/read data with function references in it?

2011-11-11 Thread Bill Robertson
If I use pprint and read-string to serialize and deserialize data w/o function references it works o.k. This is clojure 1.3. e.g. save something to disk, restart the vm, read it in ok. user= (def foo {:a 1 :b 2 :c [more stuff]}) user= (def output (java.io.FileWriter. foo.clj)) user=

Re: How do I store/read data with function references in it?

2011-11-11 Thread Chris Perkins
It looks like your (:foo d) is a symbol. ((:foo d) 4 5) is trying to look itself up as a key in the map you provided, which is 4. Since that's not a map, the lookup fails and it returns the default value you provided: 5. It's very forgiving that way :) As for your main question, about how to

Doric 0.6.0

2011-11-11 Thread joegallo
I just released a new version of doric (https://github.com/joegallo/doric) -- it's a fun little utility library that you might want to look at if you're using clojure.pprint/print-table, but want a few more features than it provides. This version includes support for generating csv, raw text,

Adding a jar to dependencies in lein

2011-11-11 Thread myriam abramson
I want to interface with the Jericho html-parser available from sourceforge. How do I specify it in project.clj for lein to fetch? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that

Re: Adding a jar to dependencies in lein

2011-11-11 Thread joegallo
Go to search.maven.org, and type in jericho-html. That'll take you to some results pages that will tell you the versions that are available, and also the correct groupId and artifactId. Then you add into project.clj the following [groupId/artifactId version]. In this case,

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread Jules
Here is a Python version (http://pastebin.com/reW5eaCy): def valid(a,b,c,d): return set(w*a + x*b + y*c + z*d for w in [-1,0,1] for x in [-1,0,1] for y in [-1,0,1] for z in [-1,0,1]) set(range(1,41)) ws = [(a,b,c,d) for a in

Re: How do I store/read data with function references in it?

2011-11-11 Thread Bill Robertson
So far its looking like I can't. I will just have to work around it then. NBD. Thanks On Nov 11, 12:02 pm, Chris Perkins chrisperkin...@gmail.com wrote: It looks like your (:foo d) is a symbol.  ((:foo d) 4 5) is trying to look itself up as a key in the map you provided, which is 4. Since

Re: scheme to clojure translation

2011-11-11 Thread Brian Goslinga
On Nov 8, 10:08 pm, Aquahappy joshua.ay...@gmail.com wrote: Hi Jim, Thanks so much! Using 'def' instead of 'defn' when defining a function composed of functions was what I was missing. I can't believe I spent an hour trying to figure this out -- it seems very obvious now. Doh! :) Notice

Re: All subsets of a vector

2011-11-11 Thread neveu
On Nov 9, 2:47 pm, Shoeb Bhinderwala shoeb.bhinderw...@gmail.com wrote: ([a] [a b] [a b c] [a b c d]) It should be pointed out that this result -- while it may be what you actually want -- is not all subsets of [a b c d]. For that you might want to use combinatorics/subsets: user= (C/subsets [a

Getting index of char from end

2011-11-11 Thread jongwon.choi
Hi I'm wondering the best way to express: (position #\a abba :from-end t) Should I use interop? (.lastIndexOf abba (int \a)) Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread Timothy Baldridge
I wonder if you can make the cKanren version just as declarative as this one (cKanren's purpose being declarative). I don't think the Python version could be considered declarative. One of the concepts behind logic programming (and to some extent declarative programming) is that you can simply

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread Jules
In the same way the cKanren version is syntactic sugar around imperative code. Declarative is not a property of a language, it's a property of code that says how close to a mathematical specification the code is. My Python code is much more declarative than the given cKanren code in that regard.

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread Timothy Baldridge
My Python code is much more declarative than the given cKanren code in that regard. Just compare: http://dosync.posterous.com/another-taste-of-ckanren I don't think you understand what declarative programming is at its core. Declarative programming To borrow from the ever-present wikipedia:

Re: Open source Clojure projects

2011-11-11 Thread Timothy Washington
Those are 2 very good links so far. You can always look at the Clojure Toolbox to get an idea of the landscape. - http://www.clojure-toolbox.com/ But the github link, though, will take you closer to what different people are working on. It is a good idea though, to step back and try to

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread Jules
Are we reading the same cKanren code? I'll give you that the matches definition is declarative, but then read checko and subchecko. They are all about (recursive) control flow. Where does the specification say anything remotely close to the checko and subchecko relations? In contrast to this, the

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread Jules
Here is a new program. Perhaps you would consider this declarative: def valid(a,b,c,d): weights = set(w*a+x*b+y*c+z*d for (w,x,y,z) in product([-1,0,1],repeat=4)) return weights = set(range(1,41)) ws = [(a,b,c,d) for (a,b,c,d) in product(range(1,41),repeat=4) if a = b = c

need help eliminating ordinary recursion/thinking the Clojure way

2011-11-11 Thread Mike
I'm having a conceptual problem, thinking functionally, and I was hoping the fine Clojurians could take a peek. Boiled down, I need to do a combination of map and reduce on a collection. My walker needs to look at pairs along the collection, but then sort of inject new values and restart when

Re: using sqlite3

2011-11-11 Thread loonster
On Nov 8, 12:47 pm, loonster tbur...@acm.org wrote: After searching long and hard, there really isn't any good documentation for using sqlite3 with clojure 1.3.  Any help connecting to an existing sqlite3 db and performing selects and updates greatly appreciated.   Tim Thanks all. In the

Re: need help eliminating ordinary recursion/thinking the Clojure way

2011-11-11 Thread Michael Gardner
Since you're given a sorted list of intervals, you don't actually need to restart the whole merging process from the start after each merge; you can just replace the last interval in your output with the new, merged interval and continue from there. So `reduce' is the perfect tool for the job;

Re: need help eliminating ordinary recursion/thinking the Clojure way

2011-11-11 Thread Mike
Ahhh...excellent, I see why I was blind. =) If you just build your reduction collection in reverse, then the head of the reduction is always the one you want to compare with as you traverse the incoming collection. So you either cons one item or two onto the result, and when you're all done

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread David Nolen
Can you reorder your statements without changing the meaning of your program? For example you cannot move the placement of the return expression. David On Fri, Nov 11, 2011 at 8:09 PM, Jules julesjac...@gmail.com wrote: Here is a new program. Perhaps you would consider this declarative: def

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread David Nolen
(define (matches n) (run #f (q) (fresh (a b c d s1 s2) (== q `(,a ,b ,c ,d)) (domfd a b c d s1 s2 (range 1 n)) (all-differentfd `(,a ,b ,c ,d)) (== a 1) (=fd a b) (=fd b c) (=fd c d) (plusfd a b s1) (plusfd s1 c s2) (plusfd s2 d n) (checko

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread Ambrose Bonnaire-Sergeant
I assume the cKanren version can run backwards with a little tweak? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread David Nolen
Excellent point Ambrose ;) And here it is: (define (subchecko w sl r o n) (conde ((== sl ()) (fresh (a d) (domfd a (range 1 100)) (conde ((conso a d r) (plusfd a 1 w) (conso w r o)) ((== r '()) (conso w r o) ((fresh (a b c

Re: A Taste of cKanren (via a coding challenge)

2011-11-11 Thread David Nolen
Also note that even given all this generality over the Python code - the earlier Python implementation takes ~300ms and this implementation takes 900ms on my machine. Quite a bit slower than ~12ms. Inferring 40 takes even less time of course - ~8ms. But really the execution time is just icing on

classpath on seesaw????

2011-11-11 Thread jayvandal
I am trying to run the examples in seesaw.I must not have seeesaw installed correctly. any help please Microsoft Windows [Version 6.0.6000] Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\cd cljr C:\cljrjava -jar c:/clojure-1.3.0.jar c:/cljr/kitchensink.clj Error: Unable to

Re: Getting index of char from end

2011-11-11 Thread Jestan Nirojan
I think regex free solution is best for this (defn last-indexof [s c] (- s (filter #(= c %)) count dec) On Nov 12, 3:36 am, jongwon.choi oz.jongwon.c...@gmail.com wrote: Hi I'm wondering the best way to express:      (position #\a abba :from-end t) Should I use interop?