Re: better error messages > smaller stack traces

2011-03-03 Thread Daniel Werner
On 2 March 2011 09:32, Alan wrote: > '(apply + 1 1) would be how you create a list of those symbols. > ('apply + 1 1) says "call the function 'apply with the arguments of + > 1 and 1". Note that this will still break at runtime because Integers are not seqable. :-) You probably want either (appl

Re: Master worker pattern

2011-03-03 Thread Jeff Rose
I've used something along these lines in the past for a medical imaging app. We needed to pre-fetch images and possibly pre-process them (filter, apply overlays) so that as a user was scrolling through an image set it was smooth and they weren't waiting for images to be processed. The GUI handler

Re: Serialising functions...

2011-03-03 Thread Alessio Stalla
On Wednesday, March 2, 2011 2:54:07 PM UTC+1, Jules wrote: [snip] > I don't have time to look at this any further today, but I think it is > looking promising if I can find a way to avoid class name collisions - > more hacking of clojure.lang I'm afraid :-( > > Apologies for posting all the sou

processing a socket stream

2011-03-03 Thread finbeu
Hello! I'm new to clojure and socket programming in particular and I kindly ask you to help me a little bit in how to design my application (all this is still overwhelming). This is a task I gave me to have something usefull while learning the clojure api: The scenario is as follows: I have a c

Re: Serialising functions...

2011-03-03 Thread Jules
Thanks, Alessio, I did know this, but it is a welcome addition to the thread. I reread my last posting and it was a bit confused - I've done a little research in the Compiler class and can now clarify what I think is happening. Clojure 1.3.0-alpha4 user=> (type (fn [])) user$eval1$fn__2 user=>

Re: processing a socket stream

2011-03-03 Thread James Reeves
On 3 March 2011 10:25, finbeu wrote: > But how do I notify my working threads that the cache was updated? Are > there some (clojure) patterns that I can use? Presumably you're starting your worker processes to avoid the overhead of starting a new thread each time? In which case, a better solution

Re: Serialising functions...

2011-03-03 Thread Alessio Stalla
On Thursday, March 3, 2011 11:46:03 AM UTC+1, Jules wrote: > > > > Thanks, Alessio, > > I did know this, but it is a welcome addition to the thread. > Ok. Classloaders are a tricky matter and many people don't have clear ideas about them - sorry for assuming you were one of those people :) >

Re: processing a socket stream

2011-03-03 Thread Miki
> But how do I notify my working threads that the cache was updated? Are > there some (clojure) patterns that I can use? > > add-watch? (http://clojuredocs.org/clojure_core/clojure.core/add-watch) -- You received this message because you are subscribed to the Google Groups "Clojure" group. T

Re: Serialising functions...

2011-03-03 Thread Jules
On Mar 3, 1:22 pm, Alessio Stalla wrote: > On Thursday, March 3, 2011 11:46:03 AM UTC+1, Jules wrote: > > > Thanks, Alessio, > > > I did know this, but it is a welcome addition to the thread. > > Ok. Classloaders are a tricky matter and many people don't have clear ideas > about them - sorry for

Re: processing a socket stream

2011-03-03 Thread finbeu
With my limited clojure skills I just managed to get the create-server up and running :-) Now I found out that I don't know how to do the following thing (sorry for my beginner questions): The stream arrives with a sequence of 10 characters. These 10 characters (e.g. 000190) give me the exac

Clojure on JS VMs

2011-03-03 Thread Timothy Baldridge
I know we have Scriptjure. But has there been any concentrated effort to port Clojure to JS? This may sound odd, but personally I would love to use Clojure in the browser. Scriptjure would work fairly well, but from what I see, it doesn't support persistent maps and instead relies on JS objects. T

Re: processing a socket stream

2011-03-03 Thread James Reeves
On 3 March 2011 14:39, finbeu wrote: > But I have right now no clue to do this (navigating to the stream > forth by a fixed number of bytes). Is there a clojure function to do > this or do I have to fall back to java? You're better off falling back to Java for this. Clojure doesn't yet have a nat

Re: Clojure on JS VMs

2011-03-03 Thread Joost
On Mar 3, 3:56 pm, Timothy Baldridge wrote: > I know we have Scriptjure. But has there been any concentrated effort > to port Clojure to JS? This may sound odd, but personally I would love > to use Clojure in the browser. Scriptjure would work fairly well, but > from what I see, it doesn't support

Re: Clojure on JS VMs

2011-03-03 Thread James Reeves
On 3 March 2011 14:56, Timothy Baldridge wrote: > I know we have Scriptjure. But has there been any concentrated effort > to port Clojure to JS? This may sound odd, but personally I would love > to use Clojure in the browser. Scriptjure would work fairly well, but > from what I see, it doesn't sup

Re: processing a socket stream

2011-03-03 Thread finbeu
James thx. That is what I need for my project: Some coaching when to fall back to java, when to use clojure function and so on. That's cool. Rgds - Finn On 3 Mrz., 15:59, James Reeves wrote: > On 3 March 2011 14:39, finbeu wrote: > > > But I have right now no clue to do this (navigating to the

Re: Swank fix for slime cvs

2011-03-03 Thread Fred Concklin
You should patch and send upstream. fpc -- 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 unsubs

Re: Clojure on JS VMs

2011-03-03 Thread Chouser
On Thu, Mar 3, 2011 at 9:56 AM, Timothy Baldridge wrote: > I know we have Scriptjure. But has there been any concentrated effort > to port Clojure to JS? This may sound odd, but personally I would love > to use Clojure in the browser. Scriptjure would work fairly well, but > from what I see, it do

Re: Master worker pattern

2011-03-03 Thread Zlatko Josic
My company have made system based on some kind of such architecture. It is parkng service for cites. You have parts of some streets where parking is allowed. That parts have name and phone number. For example Zone 1 and 9111. People use mobile phones for pay parking. They send sms message to 9111 n

jME3 and Clojure

2011-03-03 Thread Dustin Withers
Hello All, In case there is any interest I took the time to figure out the correct repositories and dependencies to get the jME3 tutorial app to work. I've posted about it here: http://7sudos.com/blog/clojure-jme3 Regards, -dustin -- You received this message because you are subscribed to the G

Re: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread Sam Ritchie
I'd like to bump this, with the question rephrased: Is there a way to call commands from a JVM process's REPL in any way other than pasting it in to that REPL? Specifically, is there a way to tell an active REPL to re-enter its current namespace? On Tue, Mar 1, 2011 at 8:50 AM, Sam Ritchie wrote

Re: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread David Nolen
On Thu, Mar 3, 2011 at 12:39 PM, Sam Ritchie wrote: > I'd like to bump this, with the question rephrased: > > Is there a way to call commands from a JVM process's REPL in any way other > than pasting it in to that REPL? Specifically, is there a way to tell an > active REPL to re-enter its current

using records in Java

2011-03-03 Thread Earl J. Wagner
Hi all, I'm running into a problem with Java code using records defined in Clojure (1.2.0) code. Here's the Clojure code: (ns t.core (:gen-class)) (defrecord TRecord [a b c]) (compile 't.core) I run Lein (1.3) to compile this and generate a jar file. Inside the jar file I see an entry for the

Re: Master worker pattern

2011-03-03 Thread Jonathan Mitchem
So, fundamentally, it's an architecture for dealing with "trivially parallel" problems? Would that be an accurate summary? (Not to imply your problems are trivial.) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: using records in Java

2011-03-03 Thread Aaron Cohen
On Wed, Mar 2, 2011 at 11:38 PM, Earl J. Wagner wrote: > > Then I try to compile Java code to use it: > > import java.lang.reflect.Method; > import t.core; > import t.core.TRecord; > > Attempting to compile this with the jar in the classpath produces a > "cannot find symbol" error for the TRecor

Re: Master worker pattern

2011-03-03 Thread Zlatko Josic
It is most suitable for parallel processing where you have lot of tasks that can be independently processed. If your tasks have shared states things are going to be more complicated. Fortunately this is changed with languages like Scala/Clojure. In both you have STM(Software transaction memory ) ap

Re: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread Daniel Solano Gomez
On Thu Mar 3 09:39 2011, Sam Ritchie wrote: > Is there a way to call commands from a JVM process's REPL in any way other > than pasting it in to that REPL? Specifically, is there a way to tell an > active REPL to re-enter its current namespace? I'm not sure if this answers your question, but have

Re: using records in Java

2011-03-03 Thread Daniel Solano Gomez
On Thu Mar 3 13:48 2011, Aaron Cohen wrote: > On Wed, Mar 2, 2011 at 11:38 PM, Earl J. Wagner > wrote: > > > > > Then I try to compile Java code to use it: > > > > import java.lang.reflect.Method; > > import t.core; > > import t.core.TRecord; > > > > Attempting to compile this with the jar in th

Re: using records in Java

2011-03-03 Thread Aaron Cohen
On Thu, Mar 3, 2011 at 2:24 PM, Daniel Solano Gomez wrote: > On Thu Mar 3 13:48 2011, Aaron Cohen wrote: > > On Wed, Mar 2, 2011 at 11:38 PM, Earl J. Wagner < > dont.spam.e...@gmail.com>wrote: > > Well, t.core exists because in his ns declaration he included > :gen-class. Now, this isn't necessa

Re: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread Sam Ritchie
David, not a problem! I was trying to put together a patch, but stumbled on this one issue, and figured the clojure list might be able to help out with the more general question, here. Exact steps: 1. Open textmate project 2. run "cake repl" at a terminal, inside the project directory 3.

Re: easier exit

2011-03-03 Thread rogerdpack
On Feb 25, 9:43 am, Stuart Halloway wrote: > > Hello all. A bit new to clojure here.  Anyway I found it a bit > > difficult to exit from a REPL. > > Would a patch to make it give instructions (like Python's > > > C:\>c:\installs\Python26\python.exe > exit > > Use exit() or Ctrl-Z plus Retur

Re: easier exit

2011-03-03 Thread rogerdpack
> > Also is there any way to contribute patches to the clojure website > > itself? (maybe put it up on github too?) > > Instructions on the patch process are > athttp://dev.clojure.org/display/design/JIRA+workflow.  Issues waiting for > patches are > athttp://dev.clojure.org/jira/secure/IssueNa

Re: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread David Nolen
On Thu, Mar 3, 2011 at 4:12 PM, Sam Ritchie wrote: > David, not a problem! I was trying to put together a patch, but stumbled on > this one issue, and figured the clojure list might be able to help out with > the more general question, here. > > Exact steps: > >1. Open textmate project >2

Writing a generic function for getting any value for a key

2011-03-03 Thread HB
Hi, I'm trying to write a function that gets the value for a key of a map. (def *places* {:room "Nice room" :basement "what ever"}) (defn describe-place [place places] (places place)) (describe-place :room *places*) Of course it isn't running :) What should I do? Thanks

Re: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread Lee Spector
On Mar 3, 2011, at 5:53 PM, David Nolen wrote: > > Thanks for the detailed description. Will look into it. > > David FWIW I posted this as issue #13 on the textmate-clojure github site some time back, and Sam provided some confirmation there. I'd love to use textmate-clojure regularly but thi

Re: Writing a generic function for getting any value for a key

2011-03-03 Thread Ken Wesson
On Thu, Mar 3, 2011 at 8:33 PM, HB wrote: > Hi, > > I'm trying to write a function that gets the value for a key of a map. > > (def *places* {:room "Nice room" >                    :basement "what ever"}) > > (defn describe-place [place places] >   (places place)) > > (describe-place :room *places

Re: Writing a generic function for getting any value for a key

2011-03-03 Thread Alan
Copied and pasted straight from your post to my REPL it works fine. Maybe verify that you're actually doing what you think you're doing? That said, this function already exists: it's called get. user=> (def *places* {:room "Nice room" :basement "what ever"}) #'user/*pla

Re: Writing a generic function for getting any value for a key

2011-03-03 Thread .Bill Smith
I'm not sure what you want describe-place to do, but you don't need a new function to get the value for a key of a map. user=> (def *places* {:room "Nice room" :basement "what ever"}) #'user/*places* user=> (:room *places*) "Nice room" user=> (*places* :room) "Nice room" user=> (:basement *place

Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Dear Clojure Group, I am currently reading the online book Pro Git. In chapter 7.4 (section “Enforcing a User-Based ACL System”) there is a task of reading in an acce

Re: Writing a generic function for getting any value for a key

2011-03-03 Thread HB
Yes indeed, it runs on my REPL too! However, if I save the code to a file and try to run it, I got this exception: Exception in thread "main" java.lang.IllegalArgumentException: Wrong number of args (1) passed to: user$describe-location (wizard-game.clj: 0) On Mar 4, 3:59 am, Alan wrote: > Copi

Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Dear Clojure Group, I am currently reading the online book Pro Git . In chapter 7.4 (section “Enforcing a User-Based ACL System”) there is a task of reading in an access control list (ACL) file, such as the following # avail/unavail

Re: CLR classpath

2011-03-03 Thread Timothy Pratley
On Wed, Mar 2, 2011 at 8:39 AM, dmiller wrote: > (1)  I think the copy solution is the easiest. Ok sounds good > (2)  I'll have to look at the ambiguous match problem. User error on my part; I figured out that mixing .NET versions is bad... switch to compiled from source and it is working beau

Re: Writing a generic function for getting any value for a key

2011-03-03 Thread HB
Sorry, it is: Exception in thread "main" java.lang.IllegalArgumentException: Wrong number of args (1) passed to: user$describe-place (wizard-game.clj: 0) On Mar 4, 4:12 am, HB wrote: > Yes indeed, it runs on my REPL too! > However, if I save the code to a file and try to run it, I got this > exc

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stuart Halloway
> Dear Clojure Group, > > I am currently reading the online book Pro Git. In chapter 7.4 (section > “Enforcing a User-Based ACL System”) there is a task of reading in an access > control list (ACL) file, such as the following > > # avail/unavail | users | path > avail|nickh,pjhyett,defunkt,tpw

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread gaz jones
i was gonna suggest this: (let [users (->> (split (slurp "acl") #"\n") (map #(split % #"\|")) (map (fn [[a u p]] [a (split u #",") p])) (filter (fn [[a _ _]] (= "avail" a))) (mapcat (fn [[_ users path]]

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Mark Engelberg
Don't be afraid to split your work across multiple functions. Not only is this clearer, but you can then test the functions independently. So something like this: (defn access-map-add-users [access-map users path] (apply merge-with into access-map (for [user users] {user [path]}))) (

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Mark Engelberg
It's also worth noting that you can translate the Ruby code almost line for line if you make use of Clojure's atoms to adopt a more "imperative" approach. In general, it's more satisfying to find a pure functional way to solve a problem, but while you're transitioning from Ruby, it's not unreasona

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Mark Engelberg
On Thu, Mar 3, 2011 at 7:35 PM, Mark Engelberg wrote: >        (when (not= avail "avail") Whoops, should be: (when (= avail "avail") -- 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 t

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Thank you all so much for helping me improve my code! I personally find Stuart's suggestion to be the most readable. The use of the ->> macro makes the workflow quite easy to follow. I hope that with some more experience I will be able to see these patterns myself and adapt my code accordingly

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Mark Engelberg
On Thu, Mar 3, 2011 at 9:15 PM, Stefan Rohlfing wrote: > I personally find Stuart's suggestion to be the most readable. The use of > the ->> macro makes the workflow quite easy to follow. Yes, both the -> and ->> macros are useful. Unfortunately, about half of Clojure's functions put the "object

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
You are perfectly right. Organizing the code so that -> or ->> an be applied is key here. Unfortunately, only if all functions to be composed follow the same pattern of either 'insert first' or 'insert last' can these macros be used. -- You received this message because you are subscribed to t

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Justin Kramer
'for' can be handy when unpacking compound lines: (ns foobar (:require [clojure.java.io :as io])) (defn parse-acl [acl-file] (with-open [r (io/reader acl-file)] (apply merge-with into (for [[status users path] (map #(.split % "\\|") (line-seq r)) :when (= "avail" stat

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Thanks for your suggestion. Using the 'for' macro here makes the main part of the parse function much clearer. -- 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 mem