Re: Question about data structures and encapsulation

2011-06-16 Thread Ken Wesson
On Fri, Jun 17, 2011 at 12:58 AM, Ryan Twitchell wrote: > Just for reflection: > What would you do with an existing class which had a getName() method, > when you suddenly realized you wanted getFirstName() and getLastName() > instead?  Or the reverse? If you can't refactor the class, that's a re

Re: Question about data structures and encapsulation

2011-06-16 Thread Ryan Twitchell
Regarding JavaBeans and the like, more often than not I've found that when getters and setters do not reference fields directly, they are contributing to a composition: as an adapter, a facade, or whatever- you-please. It is not quite as often that getters simply return a calculation based on data

Re: Best practice for distributing a standalone clojure command line utility

2011-06-16 Thread Miki
One more option is to embed the jar in base64 encoding in a script, extract the jar to a temp location and run it. The following Perl script does that (it uses the base64 executable, but you can probably use MIME::Base64 as well). #!/usr/bin/env perl $jar = "/tmp/lp-$ENV{USER}.jar"; unless (-e

Re: Swank-Inject Issue

2011-06-16 Thread Asim Jalis
Sweet. That worked. Thanks! On Thu, Jun 16, 2011 at 1:32 PM, Johan Wirde wrote: > Hi! > I have only built on OSX so far which is why I haven't noticed this > problem. Apparently the com.sun.jdi classes are packaged differently than on > other platforms (there is no tools.jar on OSX). > The best s

Re: Best practice for distributing a standalone clojure command line utility

2011-06-16 Thread Miki
> A few approaches I have thought about: 1) Upload the stand alone jar > to github and have the "gantry" script pull down the standalone into > ~/.gantry and construct the command line. 2) Create a cake wrapper > (not preferred because it introduces a dependency). 3) Forget the > wrapper and

Re: Java interop: casting

2011-06-16 Thread Stuart Halloway
Hi Gregg, It appears that LocalServiceTestHelper's constructor takes an array of LocalServiceTestConfig. Try (def bar (LocalServiceTestHelper. (into-array LocalServiceTestConfig [foo]))) Stu Stuart Halloway Clojure/core http://clojure.com > Hi, > > I'm trying to make the GAE local testing s

Re: Am I getting back a vector of lines and can I split each line?

2011-06-16 Thread octopusgrabbus
BTW I changed (:require [clojure.contrib.string :as str]) to (:require [clojure.string :as str]) and the problem persists. On Jun 16, 6:07 pm, octopusgrabbus wrote: > This Clojure program: > > ns test-csv >   (:require [clojure.contrib.string :as str]) >   (:import (java.io BufferedReader FileRea

Am I getting back a vector of lines and can I split each line?

2011-06-16 Thread octopusgrabbus
This Clojure program: ns test-csv (:require [clojure.contrib.string :as str]) (:import (java.io BufferedReader FileReader StringReader)) (:use clojure-csv.core)) (defn process-file [file-name] (with-open [br (BufferedReader. (FileReader. file-name))] (print

Re: Properly including clojure-contrib

2011-06-16 Thread octopusgrabbus
Thanks. That did it. On Jun 16, 5:46 pm, Benny Tsai wrote: > Hi cmn, > > A few things: > > 1. The warnings you see are because the clojure.contrib.string namespace > defines several functions that have the same name as core functions (repeat, > reverse, etc.).  The recommended way to pull in name

Re: Properly including clojure-contrib

2011-06-16 Thread Mark Rathwell
The clojure.contrib.string namespace contains many function names which are already defined clojure.core. So, by :use-ing clojure.contrib.string, you will be replacing the core functions with the string functions. Rarely do you really want to do this. It is generally best to :require instead of

Re: Properly including clojure-contrib

2011-06-16 Thread Benny Tsai
Hi cmn, A few things: 1. The warnings you see are because the clojure.contrib.string namespace defines several functions that have the same name as core functions (repeat, reverse, etc.). The recommended way to pull in namespaces like that is to do (:require [clojure.contrib.string :as str]),

Re: Properly including clojure-contrib

2011-06-16 Thread octopusgrabbus
I don't know what I'm doing wrong. After adding (:use clojure.contrib.string) to (ns test-csv (:gen-class) (:import (java.io BufferedReader FileReader StringReader)) (:use clojure-csv.core) (:use clojure.contrib.string)) (defn process-file [file-name] (with-open [br (BufferedReader.

Re: Properly including clojure-contrib

2011-06-16 Thread Damon Snyder
Hi cmn, I think if you add clojure.contrib.string to your use or simply add (:use clojure.contrib.string). I think that should fix it. Damon On Jun 16, 12:16 pm, octopusgrabbus wrote: > What is the proper way to :use clojure contrib so split resolves as a > symbol? > > ns test-csv >   (:gen-clas

Best practice for distributing a standalone clojure command line utility

2011-06-16 Thread Damon Snyder
Hi Everyone, I'm have a side project that I'm working on that I want to distribute as a standalone script. This is probably best illustrated as an example. What I would like to be able to do is give users a script, so they can do: gantry -H example.host.com -f examples/tasks.clj uptime Instead

Java interop: casting

2011-06-16 Thread Gregg Reynolds
Hi, I'm trying to make the GAE local testing stuff (http://code.google.com/ appengine/docs/java/tools/localunittesting.html) work with Clojure and running into a cast problem. Specifically, the example shows private final LocalServiceTestHelper helper = new LocalServiceTestHelper(new L

Re: Swank-Inject Issue

2011-06-16 Thread Johan Wirde
Hi! I have only built on OSX so far which is why I haven't noticed this problem. Apparently the com.sun.jdi classes are packaged differently than on other platforms (there is no tools.jar on OSX). The best solution I could come up with involved using a new feature from lein 1.6.0-SNAPSHOT (:extra

Re: 2011 State of Clojure survey

2011-06-16 Thread octopusgrabbus
Thanks for posting last year's survey as well as notifying us about this year's. On Jun 16, 10:26 am, Chas Emerick wrote: > Last year's State of Clojure survey[1] was such a success and yielded such > valuable data about the Clojure community that I had no choice but to do it > all again this y

Properly including clojure-contrib

2011-06-16 Thread octopusgrabbus
What is the proper way to :use clojure contrib so split resolves as a symbol? ns test-csv (:gen-class) (:import (java.io BufferedReader FileReader StringReader)) (:use clojure-csv.core) (:use [clojure.contrib.def])) (defn process-file [file-name] (with-open [br (BufferedReader. (FileR

Re: Modelling complex data structures (graphs and trees for example)

2011-06-16 Thread lambdatronic
My 2c: Regarding learning how to model a complex data structure in a functional paradigm: I can think of few resources which sum up the proper mindset you need to get into better than the canonical Clojure essay on state and identity, found here: http://clojure.org/state Regarding how t

Re: Question about data structures and encapsulation

2011-06-16 Thread Caleb
Colin, I just read this definition from SICP, which made me think about your question again: "In general, the underlying idea of data abstraction is to identify for each type of data object a basic set of operations in terms of which all manipulations of data objects of that type will be expressed

Re: Modelling complex data structures (graphs and trees for example)

2011-06-16 Thread Andreas Liljeqvist
I would make the graph immutable. If performance is a objective it might not work though. My tip for learning it: Sit down and think about the problem. Consider your Clojure structures. 2011/6/16 Colin Yates > (newbie warning) > > Our current solution is an OO implementation in Groovy and Java.

Re: Modelling complex data structures (graphs and trees for example)

2011-06-16 Thread Raoul Duke
On Thu, Jun 16, 2011 at 7:08 AM, Colin Yates wrote: > (newbie warning) > any "domain driven design with functional programming" type resources? have you googled at all? seriously, graphs & fp are standard fare in the fp world! i'd expect there to be a zillion docs about doing it in other fp langu

Re: clojure-csv Column or field extraction

2011-06-16 Thread octopusgrabbus
Many thanks. On Jun 16, 12:18 pm, David Santiago wrote: > Change the first line to something like (def csv (parse-csv (slurp > "path/to/my/file.csv"))). > >   -  David > > On Thu, Jun 16, 2011 at 8:20 AM, octopusgrabbus > > > > > > > > wrote: > > I would like to modify the examples given > > > u

Re: List comprehension not running

2011-06-16 Thread Steve Miner
(dotimes [x 10] ...) should do the trick if you're just interested in side effects. On Jun 16, 2011, at 12:24 PM, Baishampayan Ghose wrote: > 'for' is not recommended for causing side-effects. Since you are not using > the return value of the for comprehension, the lazy sequence is not getting

TriClojure would love to hear you speak

2011-06-16 Thread Chris Redinger
Hey all! Do you have a topic you'd like to talk to somebody about? Why not head on over to Durham and speak at our monthly TriClojuremeeting?! We're open to hearing about all sorts of topics. Speaking at user groups is a fantastic way to improve your speaking ability

Re: List comprehension not running

2011-06-16 Thread Baishampayan Ghose
'for' is not recommended for causing side-effects. Since you are not using the return value of the for comprehension, the lazy sequence is not getting realised. You can either use 'doall' around it or better still, use 'doseq'. Hope that helps. Regards, BG --- Sent from phone. Please excuse bre

Re: clojure-csv Column or field extraction

2011-06-16 Thread David Santiago
Change the first line to something like (def csv (parse-csv (slurp "path/to/my/file.csv"))). - David On Thu, Jun 16, 2011 at 8:20 AM, octopusgrabbus wrote: > I would like to modify the examples given > > user=> (def csv (parse-csv "1,2,3\n4,5,6\n7,8,9")) > #'user/csv > user=> (nth (nth csv 1)

List comprehension not running

2011-06-16 Thread Thomas
Hi All, I have a ref with a watcher on it, and I call another function from the watch function. I can see that call happens, but the for construct doesn't seem to run. Any idea why this is? Am I doing something wrong? Here is a simplified version of the code: (def numbers (ref #{1 2 3 4 5 6 7 8

Screencast: Clojure + Emacs + slime + swank + cake + Overtone

2011-06-16 Thread Sam Aaron
Hi there, I just finished making a screencast primarily for new Overtone users on how to get set up with Emacs as a primary editor: http://vimeo.com/25190186 It turns out that this should be pretty useful for Clojure hackers in general as it's really a screencast on how to set up a Clojure env

2011 State of Clojure survey

2011-06-16 Thread Chas Emerick
Last year's State of Clojure survey[1] was such a success and yielded such valuable data about the Clojure community that I had no choice but to do it all again this year! The 2011 State of Clojure survey opened yesterday, and will remain open until Monday, June 20th: http://cemerick.com/2011/

Modelling complex data structures (graphs and trees for example)

2011-06-16 Thread Colin Yates
(newbie warning) Our current solution is an OO implementation in Groovy and Java. We have a (mutable) Project which has a DAG (directed acyclic graph). This is stored as a set of nodes and edges. There are multiple implementations of nodes (which may themselves be Projects). There are also mult

Functions destructuring maps in the arglist

2011-06-16 Thread Tassilo Horn
Hi all, I have some functions that use destructuring on a map parameter, and it seems I have a false assumption on the workings. Take for example this one: (defn foo [{:keys [a b] :or {a 1 b 2} :as all}] [(hash-map :a a :b b) all]) I expected it to always return a vector of two equa

Aw: Re: Question about data structures and encapsulation

2011-06-16 Thread Meikel Brandmeyer
Hi, one could use lazymap: https://bitbucket.org/kotarak/lazymap. Unfortunately, it is broken at the moment. Have to bring up-to-date with 1.2 and later. (defn person [name year-of-birth] (lazy-hash-map :name name :age (- 2011 year-of-birth))) The actual difference would only be calculated

Re: using regex reader macro with generated code

2011-06-16 Thread Daniel Werner
On Jun 16, 4:47 am, Alex Baranosky wrote: > IS it possible to use the regex reader macro #"" with generated code?  What > I mean is do something like: > > #"${(join "|" (range 1 1))}" > > I'm using ${...} to mean string interpolation, though I know Clojure doesn't > have that syntax.  Is there

Re: Question about data structures and encapsulation

2011-06-16 Thread Laurent PETIT
2011/6/16 Mikkel : > This could be one way to solve the problem in the example and keep a > uniform API: > (def joe {:age ((fn [] (- 2011 1979)))}) > (:age joe) > #> 32 > > Any comments on that? You're applying the function immediately. It's not different than doing (let [age ((fn [] (- 2011 1979)

Re: Question about data structures and encapsulation

2011-06-16 Thread Mikkel
This could be one way to solve the problem in the example and keep a uniform API: (def joe {:age ((fn [] (- 2011 1979)))}) (:age joe) #> 32 Any comments on that? On Jun 15, 8:41 pm, Colin Yates wrote: > Newbie so go gentle please :).   > > I am an experienced OO Java developer (decade +) conside

Clojure Agents at AGERE! @ SPLASH (?)

2011-06-16 Thread aricci
Dear Clojurers given the Clojure support to concurrent programming and in particular to a notion of "agent", I thought you may be interested to a workshop running in SPLAH 2011 called AGERE! devoted to foster the discussion and research about ACTORS and AGENTS as paradigm for computer

Re: clojure-csv Column or field extraction

2011-06-16 Thread octopusgrabbus
I would like to modify the examples given user=> (def csv (parse-csv "1,2,3\n4,5,6\n7,8,9")) #'user/csv user=> (nth (nth csv 1) 2) ;; Get 2nd row, last column. "6" user=> (-> csv (nth 1) (nth 2)) ;; Another way to do it. "6" user=> (defn get-column [parsed-csv col] (map #(nth % col) parsed-csv))

Re: Vote for Clojure as Most Innovative Java Technology

2011-06-16 Thread Ambrose Bonnaire-Sergeant
Where's the "Most Innovative of the last decade" button? :) -- Ambrose On Thu, Jun 16, 2011 at 8:58 PM, Stuart Sierra wrote: > Do you think Clojure is the Most Innovative Java Technology of 2011? > > Vote here: http://vote.jax-awards.com/ > > -- > You received this message because you are subs

Vote for Clojure as Most Innovative Java Technology

2011-06-16 Thread Stuart Sierra
Do you think Clojure is the Most Innovative Java Technology of 2011? Vote here: http://vote.jax-awards.com/ -- 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 member

Re: Tutorial about web development with Clojure

2011-06-16 Thread Junior Zhang
So cool! -- 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 unsubscribe from this group, send email

Re: Question about data structures and encapsulation

2011-06-16 Thread Vincent
nice podcast thanks -- 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 unsubscribe from this gr

Re: using regex reader macro with generated code

2011-06-16 Thread Rasmus Svensson
2011/6/16 Alex Baranosky : > IS it possible to use the regex reader macro #"" with generated code?  What > I mean is do something like: > #"${(join "|" (range 1 1))}" > I'm using ${...} to mean string interpolation, though I know Clojure doesn't > have that syntax.  Is there a way to get this e

Re: using regex reader macro with generated code

2011-06-16 Thread Ken Wesson
On Wed, Jun 15, 2011 at 10:47 PM, Alex Baranosky wrote: > IS it possible to use the regex reader macro #"" with generated code?  What > I mean is do something like: > #"${(join "|" (range 1 1))}" > I'm using ${...} to mean string interpolation, though I know Clojure doesn't > have that syntax.

Re: Tutorial about web development with Clojure

2011-06-16 Thread Can Arel
Thanks , very helpful! 2011/6/11 Tarantoga > Hi all, > > I have implemented a small blog (posts, comments, authentication) with > Clojure using the Rails-like style of development. It is located here: > https://github.com/dbushenko/ClojureBlog. The blog uses the following > principles: > 1) MVC

Re: Question about data structures and encapsulation

2011-06-16 Thread Alessio Stalla
On Jun 16, 2:59 am, Colin Yates wrote: > Thanks for all the help, all of you.  The Clojure community has a reputation > for being helpful :) > > The example of age as a property which might change from a value to a > function was indeed a strawman, but it was just an example.  So the > consensus s