Re: function calling itself using a generic self reference call?

2012-08-05 Thread Dave Sann
It would also be a useful ability in multimethods... On Monday, 6 August 2012 16:33:15 UTC+10, Dave Sann wrote: > > I didn't know you could name functions made with fn like that. nice. > > > It would be a handy feature for defn to have maybe... > > On Monday, 6 August 2012 16:16:06 UTC+10, Carlo w

Re: function calling itself using a generic self reference call?

2012-08-05 Thread Dave Sann
I didn't know you could name functions made with fn like that. nice. It would be a handy feature for defn to have maybe... On Monday, 6 August 2012 16:16:06 UTC+10, Carlo wrote: > > > 1. would it be, or is it possible to have something generic like this? > > You could use: > > (def v1 (fn self

Re: function calling itself using a generic self reference call?

2012-08-05 Thread Baishampayan Ghose
You might want to look at the Y Combinator for this. Regards, BG On Mon, Aug 6, 2012 at 11:36 AM, Dave Sann wrote: > (this is not a question about recur) > > Suppose I have: > > (defn v1 > ([x] (v1 x [])) > ([x r] (conj r x))) > > and I decide to make v2 - for whatever reason - say I think

Re: function calling itself using a generic self reference call?

2012-08-05 Thread Carlo Zancanaro
> 1. would it be, or is it possible to have something generic like this? You could use: (def v1 (fn self ([x] (self x [])) ([x r] (conj r x))) > 2. What about anonymous fns? The same idea, just without the "def". (fn call-self ([x] (call-self x 0)) ([x y] ...))) -- You received this

function calling itself using a generic self reference call?

2012-08-05 Thread Dave Sann
(this is not a question about recur) Suppose I have: (defn v1 ([x] (v1 x [])) ([x r] (conj r x))) and I decide to make v2 - for whatever reason - say I think I have a better implementation for part of it so I start with a copy and edit: (defn v2 ([x] (v1 x [])) ([x r] (conj r (inc

Re: Question about sets

2012-08-05 Thread Sean Corfield
On Sun, Aug 5, 2012 at 7:31 PM, Evan Gamble wrote: > ...oh, and regarding the people who argue we should not use literal syntax > with non-constants, I can only shake my head in wonder. Why on Earth would > anyone seriously propose not using this elegant, concise syntax? Just to be clear, I'm not

Re: Any chance for Ratio and BigInt support in ClojureScript?

2012-08-05 Thread Olaf Delgado-Friedrichs
Thanks for the link! I didn't know that the Closure library contained an arbitrary precision type, but should have expected it. When you speak of performance, do you mean the extra cost of checking argument types for the arithmetic operators? I wonder if this could be addressed by introducing a

Re: Question about sets

2012-08-05 Thread Evan Gamble
Throwing a runtime error for duplicates in set literals is, to me, shockingly counterintuitive, regardless of whether constants or non-constants are in the literal. Mathematical set notation has a long history of admitting duplicates, for clarity in exposition, which are understood to collapse

Re: record constructor

2012-08-05 Thread Warren Lynn
On Sunday, August 5, 2012 7:23:55 PM UTC-4, Luc wrote: > > You have been referring to OOP several times in your posts, the kind of > patterns > we are talking about are these: > > http://en.wikipedia.org/wiki/Software_design_pattern > > These are the kind of design patterns OOP has been fond

Re: record constructor

2012-08-05 Thread Softaddicts
You have been referring to OOP several times in your posts, the kind of patterns we are talking about are these: http://en.wikipedia.org/wiki/Software_design_pattern These are the kind of design patterns OOP has been fond of in the last ten years. Java/C# and cie have been implementing/following

Re: Question about sets

2012-08-05 Thread Jim - FooBar();
I don't think any of the 5 clojure books out there, mentions that data-structure literals should not be used to generate vectors/maps/sets dynamically at runtime...personally I've been doing this a lot especially with vectors and maps ! never even suspected that it was wrong simply because i do

Re: Question about sets

2012-08-05 Thread Michael Gardner
On Aug 5, 2012, at 4:18 PM, Mark Engelberg wrote: > Also, although it was a breaking change to add throw-on-duplicate behavior to > many types of maps and sets, reverting back to 1.2 behavior could not > possibly be a "breaking change" in the literal sense. Anyone whose code > works right now

Re: Any chance for Ratio and BigInt support in ClojureScript?

2012-08-05 Thread David Nolen
On Sun, Aug 5, 2012 at 12:45 AM, Olaf Delgado-Friedrichs < olaf.delg...@googlemail.com> wrote: > Hi, > > I am currently learning Clojure/ClojureScript and enjoying it a lot. Since > I have a bit of code I am planning to port that requires precise rational > arithmetic, I am particular delighted by

Re: Question about sets

2012-08-05 Thread Phil Hagelberg
On Sat, Aug 4, 2012 at 11:45 PM, Mark Engelberg wrote: > My jaw is dropping here. I can't believe anyone would seriously propose > that the only things that go between [], {}, or #{} should be constants. For what it's worth, vectors behave this way in Emacs Lisp. I couldn't believe it either wh

Re: Question about sets

2012-08-05 Thread Mark Engelberg
On Sun, Aug 5, 2012 at 1:42 PM, Mark Engelberg wrote: > 3. People may differ about which flavor constructor the literals should > use, but I don't see any arguments here warranting a breaking change. Also, although it was a breaking change to add throw-on-duplicate behavior to many types of maps

Re: Question about sets

2012-08-05 Thread Mark Engelberg
On Sun, Aug 5, 2012 at 1:18 PM, Stuart Halloway wrote: > 1. Simplicity is partially about having orthogonal primitives. A > duplicate-removing collection factory cannot be sensibly used to implement > a throw-on-duplicates collection factory, nor vice versa, so both seem > equally primitive to me.

Re: Question about sets

2012-08-05 Thread Stuart Halloway
My 2c: 1. Simplicity is partially about having orthogonal primitives. A duplicate-removing collection factory cannot be sensibly used to implement a throw-on-duplicates collection factory, nor vice versa, so both seem equally primitive to me. 2. Given that both flavors are useful, they should

Re: Question about sets

2012-08-05 Thread Mark Engelberg
After reading through the links that Chas provided, here's a summary of the main points as I see them: 1. Looking through the history of this issue, no one was actually asking to be protected from accidentally typing duplicate keys in a map or set. 2. People *were* asking to be protected from t

Extracting all the strings of a web app to resource files

2012-08-05 Thread Haim Ashkenazi
Hi I'm new here :) I have a web app which I want to extract all the text out of the hiccup templates. In my very limited java experience I remember there is a good support for i18n resource files, but I don't really need the overhead of i18n. What would be a good way to do it (except for making a

Re: Playing with clojure-encog, Machine-Learning wrapper

2012-08-05 Thread Timothy Washington
Hey Jim, Yes, it absolutely crossed my mind to post this on the encog-java forum. So I did just that (see here ). Thanks very much for your quick responses so far. Tim Washington Interruptsoftware.ca 416.843.9060 On Sun, Aug 5, 2012 at 3:04 PM, Jim - F

Re: Question about sets

2012-08-05 Thread Mark Engelberg
On Sun, Aug 5, 2012 at 7:33 AM, Chas Emerick wrote: > Quoting Rich from the mailing list thread linked above: > > These are bugs in user code. Map literals are in fact read as maps, so > a literal map with duplicate keys isn't going to produce an evaluated > map with distinct keys. If you create

Re: Question about sets

2012-08-05 Thread Vinzent
Oh, right; I've said something silly. What I had in mind is something like (let [[x y] (if cond [(coll 0) (coll 1)] [default (first coll)]), which is quite common in e.g. macros with optional arguments. Also, vectors containing expressions can be used by functions returning multiple values, or

Re: record constructor

2012-08-05 Thread Warren Lynn
B) I said I hate the pattern word, let me say it bluntly, elaborate > patterns have the unique > property of fossilizing a language as soon as you start to modify the > language > to support them. Especially complex ones. > It kills evolution the day you need to meet other nee

Re: Playing with clojure-encog, Machine-Learning wrapper

2012-08-05 Thread Jim - FooBar();
Hi Tim, first of all thanks for opening a new thread for this... 2 things : The 1st paragraph is really a perfect question for the encog-java forum...I'm not sure anyone here can help with this (not even me - financial prediction with temporal data is one of those encog corners I've not had

Re: Question about sets

2012-08-05 Thread Mark Engelberg
On Sun, Aug 5, 2012 at 7:33 AM, Chas Emerick wrote: > Note that the .createWithCheck variations of all of the collections in > question are used by their "constructor" functions as well, e.g. hash-set, > hash-map, and array-map: > I hadn't noticed that, but I think that is good evidence that thi

Re: community interest in machine learning (?)

2012-08-05 Thread Timothy Washington
Heyya, So I got to playing with the core encog-java system. This thread is getting a bit long, so I put my thoughts into a new thread here: Playing with clojure-encog, Machine-Learning wrapper . But the thrust is that I need

Playing with clojure-encog, Machine-Learning wrapper

2012-08-05 Thread Timothy Washington
Hey all, This post is a fork of a thread in the post "community interest in machine learning". Some of us were starting to take a deep dive into clojure-encog and I thought it would be

Re: Overtone - Live @ Arnolfini

2012-08-05 Thread Sam Aaron
On 4 Aug 2012, at 17:23, Tom Maynard wrote: > Bravo! Standing ovation. Technical difficulties be d*mned, that was a > spectacular exhibition. I was reminded of a live premiere performance by > Karlheinz Stockhausen that I attended at the NASA auditorium in Galveston, > Texas, USA years ag

Any chance for Ratio and BigInt support in ClojureScript?

2012-08-05 Thread Olaf Delgado-Friedrichs
Hi, I am currently learning Clojure/ClojureScript and enjoying it a lot. Since I have a bit of code I am planning to port that requires precise rational arithmetic, I am particular delighted by the fact that Clojure natively supports rational and arbitrary precision numbers. I'd also like to be

Re: record constructor

2012-08-05 Thread Softaddicts
A) protocols provide benefits that multi dispatch don't like performance B) I said I hate the pattern word, let me say it bluntly, elaborate patterns have the unique property of fossilizing a language as soon as you start to modify the language to support them. Especially complex o

Re: record constructor

2012-08-05 Thread Warren Lynn
On Sunday, August 5, 2012 1:10:04 PM UTC-4, Nicolas Oury wrote: > > Constructors are not a good idea, because they tie the functionality > to the implementation. > > > You want to be able to change your record to something else without > changing your client code. > My answer to this is: eve

Re: record constructor

2012-08-05 Thread nicolas.o...@gmail.com
Constructors are not a good idea, because they tie the functionality to the implementation. You want to be able to change your record to something else without changing your client code. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: beginner questions

2012-08-05 Thread Sean Corfield
On Sun, Aug 5, 2012 at 12:53 AM, Catonano wrote: > (clojure.contrib.str-utils2/grep #"myPattern" "one row \n another row") Just as a side note, the old monolithic contrib library has been deprecated and many parts are no longer maintained (and you may have problems trying to use it with Clojure 1

Re: Question about sets

2012-08-05 Thread Sean Corfield
On Sun, Aug 5, 2012 at 3:33 AM, Vinzent wrote: > Also, I have a huge number of literal vectors with expressions inside > (typical example: (let [[x y] coll] ...) is an equvalent to [(coll 0) (coll > 1)]). A destructuring vector is not the same thing as is being discussed here: (let [[x y] coll] .

Re: Question about sets

2012-08-05 Thread Chas Emerick
On Aug 5, 2012, at 2:56 AM, Sean Corfield wrote: > On Sat, Aug 4, 2012 at 11:45 PM, Mark Engelberg > wrote: >> In any case, Clojure is already able to detect when x and y are equal in >> something like #{x y} and report it as an error. > > So do you think #{1 1} should not be an error? And {:a 1

Re: record constructor

2012-08-05 Thread Craig Brozefsky
Warren Lynn writes: >If it does not do any harm to anybody but have benefits for some people >(of course not just me), I reason it is a good feature. You should check out Perl. 8^) -- Craig Brozefsky Premature reification is the root of all evil -- You received this message because

Re: record constructor

2012-08-05 Thread Warren Lynn
On Sunday, August 5, 2012 5:56:30 AM UTC-4, Vinzent wrote: > > +1 for Warren's proposal. I thought about the same thing earlier, but > haven't shared it with community because I believed it'd be rejected. > > Though, I don't see how OOP relates to the topic of this discussion. > Records are not

Re: record constructor

2012-08-05 Thread Warren Lynn
> My point was that you don't need a factory function if there's no > "construction logic" so the record alone - the data structure - is > sufficient for a lot of cases. Similarly you can choose to use a > "factory function" even if the underlying data structure is not a > record. They are se

Re: record constructor

2012-08-05 Thread Softaddicts
As I was saying, just put your factory fns in the same name space than your defrecord and attach a doc string on it... The sole relative "nicety" of a feature should not be the driving force helping decide if it's worthwhile to implement. You have to consider what exists already. Factory fns are

Re: beginner questions

2012-08-05 Thread Catonano
Ok, I found split-lines, sorry for the noise 2012/8/5 Catonano > Hello people, > > I'm playing with Clojure and I have some silly questions. > > Is this the right place ? Is there a list or forum more apt to elementary > level questions ? > > Anyway, my question is: I have a short text, it's som

Re: record constructor

2012-08-05 Thread Jim - FooBar();
In any case, here is how a record-factory function would look like (credit goes to Chris Houser if I'm not mistaken): (defn record-factory "A factory function for records." [recordname] (let [recordclass ^Class (resolve (symbol recordname)) max-arg-count (apply max (map #(count (.getPa

Re: Question about sets

2012-08-05 Thread Vinzent
I agree with puzzler and Alex. Also, I have a huge number of literal vectors with expressions inside (typical example: (let [[x y] coll] ...) is an equvalent to [(coll 0) (coll 1)]). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g

Re: record constructor

2012-08-05 Thread Vinzent
+1 for Warren's proposal. I thought about the same thing earlier, but haven't shared it with community because I believed it'd be rejected. Though, I don't see how OOP relates to the topic of this discussion. Records are not objects; they are rather typed maps. Everyone writes that "constructor

Re: assoc! order problem

2012-08-05 Thread Christian Sperandio
Hi, By default, maps are array-map for short map and hash map for larger one. That explains why the map seems sorted at the beginning. Christian Le 5 août 2012 à 10:40, Evan Mezeske a écrit : > I know the sorted-map, but my question is : why the map is not 'ordered' when > size is larger tha

Re: assoc! order problem

2012-08-05 Thread Evan Mezeske
> > I know the sorted-map, but my question is : *why the map is not 'ordered' > when size is larger than 32 ?* > Because a hash-map is never guaranteed to be sorted. In your case, it sounds like Clojure is being smart and using a different implementation for small maps (say, less than 32 elem

Re: assoc! order problem

2012-08-05 Thread Bronsa
because of performance reasons, hash-maps are not ordered. the fact that they are ordered for the first 32 elements is just an implementation detail you shouldn't rely on Il giorno 05/ago/2012 10.10, "llj098" ha scritto: > thanks for reply, > > I know the sorted-map, but my question is : *why the

Re: Strange coercions

2012-08-05 Thread Pierre-Henry Perret
Sean, It works now.. ! I have at last precated th lein1 project. You'll see in the code a *file:// *url that is particular to my current checkout version, by default *development *. Any *tests* / *appreciations *are welcomed . Le dimanche 5 août 2012 07:36:00 UTC+2, Sean Corfield a écrit :

Re: ANN a CjOne TodoMVC implementation

2012-08-05 Thread Pierre-Henry Perret
RECTIF Must *cljs-ns-browser* browser by by hand using repl cmd: one.todomvc.repl=> *('use 'cljs-ns-browser.ns)* one.todomvc.repl=> *( sdoc ) * Have fun ! Le dimanche 5 août 2012 10:16:17 UTC+2, Pierre-Henry Perret a écrit : > > New free sources CjOne Appli at [1] > > The source tree is in bran

Re: Strange coercions

2012-08-05 Thread Pierre-Henry Perret
(defproject peer-one/peer-one "1.0.0-SNAPSHOT" :checkout-deps-shares [:source-path "src/" :deps-libs (fn [p] ((str (:root p) (:source-path p] :dependencies [[org.clojure/clojure "1.4.0"] [ring "1.0.

Re: ANN a CjOne TodoMVC implementation

2012-08-05 Thread Pierre-Henry Perret
New free sources CjOne Appli at [1] The source tree is in branch *development *. NEW: lauch automatically *cljs-ns-browser !* * * -- [1] https://github.com/phperret/peer-one.git Le dimanche 5 août 2012 01:03:46 UTC+2, Pierre-Henry Perret a écrit : > > Using it in Chrome and then typing F12 a

Re: assoc! order problem

2012-08-05 Thread llj098
thanks for reply, I know the sorted-map, but my question is : *why the map is not 'ordered' when size is larger than 32 ? * * * * * On Sunday, August 5, 2012 3:53:04 AM UTC+8, Jeff Heon wrote: > > You are using the map literal, which corresponds to the hash map. > > Use this if you want a sorted

beginner questions

2012-08-05 Thread Catonano
Hello people, I'm playing with Clojure and I have some silly questions. Is this the right place ? Is there a list or forum more apt to elementary level questions ? Anyway, my question is: I have a short text, it's some javascript source code. I'd like to apply grep onto it in order to extract e

Re: Question about sets

2012-08-05 Thread Alex Baranosky
I'm on Mark's side. #{a b} potentially throwing a runtime exception is one of those quirky Clojure-isms that would be considered bugs to anyone not deeply entrenched in the Clojure world. Let's remove the Clojure-colored glasses. -- You received this message because you are subscribed to the Go

Re: record constructor

2012-08-05 Thread Laurent PETIT
Le 5 août 2012 à 05:33, Warren Lynn a écrit : I don't think it is "OO-phobia". I think a lot of people here have > used (several) OO languages and just find the FP way better - or at > least better for the problems they are solving. > If I am proposing something like state-mutation based OOP,

Re: Question about sets

2012-08-05 Thread Mark Engelberg
On Sat, Aug 4, 2012 at 11:56 PM, Sean Corfield wrote: > On Sat, Aug 4, 2012 at 11:45 PM, Mark Engelberg > wrote: > > In any case, Clojure is already able to detect when x and y are equal in > > something like #{x y} and report it as an error. > > So do you think #{1 1} should not be an error? And