A few String functions we could implement in Clojure?

2014-07-19 Thread Pierre Masci
Hi all, just nit picking about Clojure's String API. I've been comparing it with Java's http://www.tutorialspoint.com/java/java_strings.htm, and I noticed that (not surprisingly) they are very similar. There are just 2-3 functions that exist in Java but don't have an equivalent in Clojure. I

How to control evaluation of code with cider

2014-07-19 Thread Brent Millare
Backstory: I modified the cljs.repl/repl to instead of pulling characters from *in*, but to use core.async channels, and to !! on an input-channel. When an input is received, a StringReader with the input is created and evaluation continues until either an error or printed output occur.

Re: A few String functions we could implement in Clojure?

2014-07-19 Thread Andy Fingerhut
Pierre: I maintain the cheatsheet, and I put .indexOf and .lastIndexOf on there since they are probably the most common thing I saw asked about that is in the Java API but not the Clojure API, for strings. There are also links to whole Java classes and their entire API, e.g. for file I/O, for

Re: A few String functions we could implement in Clojure?

2014-07-19 Thread Bruce Durling
Andy, How much of this reasoning do you think changes when we starting thinking about being hosted on multiple platforms (I'm thinking specifically clojure/clojurescript and cljx)? cheers, Bruce On Sat, Jul 19, 2014 at 4:17 PM, Andy Fingerhut andy.finger...@gmail.com wrote: Pierre: I

Re: A few String functions we could implement in Clojure?

2014-07-19 Thread Andy Fingerhut
I would have to defer that question to someone who makes decisions regarding what goes into Clojure/ClojureScript, and what does not. Of course, anyone else is free to create libraries that try to make portability between those two platforms easier. Perhaps someone has already taken a go at

Re: A few String functions we could implement in Clojure?

2014-07-19 Thread mascip
Thank you for your insight Andy :-) Interesting question Bruce. -- Pierre Masci On 19 July 2014 16:49, Andy Fingerhut andy.finger...@gmail.com wrote: I would have to defer that question to someone who makes decisions regarding what goes into Clojure/ClojureScript, and what does not. Of

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Alex Baranosky
What does `empty` do for non-collection types?: (empty 1) = nil (empty 123) = nil (empty :abc) = nil (empty (clojure.lang.MapEntry. a 1)) So it is actually very consistent. On Fri, Jul 18, 2014 at 6:06 PM, Brian Craft craft.br...@gmail.com wrote: hm, looks even more broken in the context of

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Mike Fikes
MapEntry is a collection: (coll? (clojure.lang.MapEntry. a 1)) ;= true (ancestors (class (clojure.lang.MapEntry. a 1))) ;= (a set that includes clojure.lang.IPersistentCollection) The docstring for empty implies it would return an empty MapEntry. But perhaps since MapEntry is a special

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Mark Engelberg
As Mike points out, it does seem that MapEntry is considered a collection and is designed to emulate a vector so that you don't really have to worry about whether you have a MapEntry or a two-element vector (and as he points out, in ClojureScript there really is no distinction between a MapEntry

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Jozef Wagner
While the c.l.MapEntry is a persistent vector, there is no such thing as an empty MapEntry persistent vector. Returning empty HAMT persistent vector instead is not a good solution, as 2 elements HAMT vector does not implement IMapEntry interface. One approach on how to solve this is in Zach's

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Brandon Bloom
I've been bitten by all three of these things in the past: 1) A MapEntry looks like a vector, but isn't. 2) Two element vectors can't be used as map entries. 3) Applying empty to a MapEntry returns nil. On Saturday, July 19, 2014 4:04:13 PM UTC-4, Jozef Wagner wrote: While the c.l.MapEntry is

ANN Elastisch 2.1.0-beta4 is released

2014-07-19 Thread Michael Klishin
Elastisch [1] is a minimalistic feature rich Clojure client for ElasticSearch. 2.1 has multiple improvements in the native client, including the long awaited aggregations support:  http://blog.clojurewerkz.org/blog/2014/07/20/elastisch-2-dot-1-0-beta4-is-released/ 1.

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Alex Baranosky
You cannot have an empty MapEntry though, because map entries always have just one size, a key and a value. I can definitely see how it can be confusing though. On Sat, Jul 19, 2014 at 4:42 PM, Brandon Bloom brandon.d.bl...@gmail.com wrote: I've been bitten by all three of these things in the

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Brandon Bloom
I understand that, but the issue that bothers me is that MapEntry prints like a vector and satisfies the clojure.core/vector? predicate. If you call first or seq or something like that on a map, your REPL will lie to you. Worse, you might even be 100% aware that you have a MapEntry instead of a

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Mike Fikes
I did a little “code archaeology” in an attempt to elucidate what Rich may had been thinking: In mid 2007, some of the persistent collection implementations had an EMPTY value defined. [1, 2]. (But, of course, no such EMPTY value was defined for MapEntrys.) Around a year later, MapEntrys were

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Mike Fikes
In *Clojure Programming* (Emerick, Carper, Grand) a swap-pairs function is defined in the section describing how empty allows you to write functions against abstractions. That function operates on sequentials, and, importantly, is carefully designed (invoking empty) so that its return type is

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Mike Thvedt
Is there a reason you want an (empty some-map-entry) to implment IMapEntry? You can already do ordinary modifications on it where it loses the type. Not sure why empty should be an exception. IMapEntry only provides key, val, and java.util.Map.MapEntry, and probably if you're modifying map

Re: unexpected behavior of clojure.core/empty

2014-07-19 Thread Brandon Bloom
It's worth mentioning that ClojureScript does not have a MapEntry type. Vectors implement IMapEntry using nth: https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L3601-L3605 And empty returns an empty vector: ClojureScript:cljs.user (empty (first {:a 1})) [] On