Using :clojure.spec.alpha/invalid inside clojure.core macros throw exception

2019-09-17 Thread Daniel Dinnyes
I am using Clojure 1.10.0 Basic example for the issue is: (let [x 42] :clojure.spec.alpha/invalid) This will result in the following exception: 2. Unhandled clojure.lang.Compiler$CompilerException 1. Caused by clojure.lang.ExceptionInfo Call to clojure.core/let did not conform to spec. #:cl

Keys spec with :additional-keys boolean option

2019-03-03 Thread Daniel Dinnyes
Hi Everyone, I am using spec for a while (currently on the version shipped with Clojure 1.10). This post is intended to be a kind-of status report, focusing on a particular issue I am facing at the moment. To explain it in detail, please have a look on this following macro I wrote, which is an

Issue with using keywords as function in a spec conformer

2019-01-31 Thread Daniel Dinnyes
Hi everyone, I have ran into an issue with spec, and suspect it is a bug. The following code throws an error: (clojure.spec.alpha/conformer :foo) The error is a java.lang.Exception and says: Unable to resalve spec; :foo This is unexpected because I intend to use the keyword as a conformer fu

Re: zipmap behaviour

2016-07-29 Thread Daniel Dinnyes
> (hash-map :a 1 :a 2) > java.lang.IllegalArgumentException: Duplicate key: :a > > > (defn my-zipmap [s1 s2] (apply hash-map (interleave s1 s2))) > #'sandbox10223/my-zipmap > > (my-zipmap [:a :b :c] (range)) > {:a 0, :c 2, :b 1} > > (my-zipmap [:a :b :

Re: zipmap behaviour

2016-07-29 Thread Daniel Dinnyes
multiple times. It would be definitely a human-friendly addition to log some warning when a key is to be defined multiple times, especially if it can avoid impact on performance. Cheers, D. On Friday, 29 July 2016 17:07:14 UTC+1, Daniel Dinnyes wrote: > > Hi All, > > This post is just t

zipmap behaviour

2016-07-29 Thread Daniel Dinnyes
Hi All, This post is just to mention my recent experience with one of the clojure.core/zipmap, by witch I was burned badly recently. Consider the following example code (def ks [:a :b :c :d :e :f :b :c :d]) (def m (zipmap ks (range))) (get m :b) > 6 Of course the "ks" in my case was like 10

Re: --> macro proposal

2013-07-19 Thread Daniel Dinnyes
> I understood David's comment differently, that the current threading > macros exist so that explicit bindings for each threaded form are not > needed for they very specific cases they intend to simplify. I'm not saying > your macro is dumb, I just don't find the sugar particularly tasty. ;-)

Re: --> macro proposal

2013-07-19 Thread Daniel Dinnyes
HUGE benefit, the reason why all the threading macros exist. Beside that restriction, this fine macro above won't struggle to take away any of the `let` goodies, unlike ->, ->>, as->, or anything. I need a beer. On Friday, July 19, 2013 3:18:15 PM UTC+1, Daniel Dinnyes wrote:

Re: --> macro proposal

2013-07-19 Thread Daniel Dinnyes
Ugh. What a pointless thread. Someone could have just said: >>> >>> --- >>> It's already in clojure 1.5. The form you are looking for is called >>> as->. >>> Your original example would be written like this: >>> >>> (as->

Re: --> macro proposal

2013-07-19 Thread Daniel Dinnyes
On Monday, July 15, 2013 11:53:09 PM UTC+1, Jeremy Heiler wrote: > > On July 15, 2013 at 6:30:28 PM, Daniel Dinnyes > (dinn...@gmail.com) > wrote: > > Hmm, good point, especially the `let` one... What is `as->`? I can't find > anything about that. > &g

Re: Proposed change to let-> syntax

2013-07-19 Thread Daniel Dinnyes
Yeah, seemingly I am still a newcomer here. As long as no one minds me coming up with "great ideas", I don't mind looking stupid either... it will improve hopefully :) On Friday, July 19, 2013 9:38:48 AM UTC+1, MichaƂ Marczyk wrote: > > On 19 July 2013 10:24, Daniel Dinnyes

Re: Proposed change to let-> syntax

2013-07-19 Thread Daniel Dinnyes
Hi, This will sound strange from me, but are these macros really to be added to the core? Firstly, I don't see they extend the language in any way new. Instead they ease some very special cases, which could have been done with the combination of existing core functions/macros just as well, and

Re: --> macro proposal

2013-07-15 Thread Daniel Dinnyes
->> is good for functions expected/designed to be partially applied. Is that correct? Cheers, Daniel On Sunday, July 14, 2013 5:39:18 PM UTC+1, Jeremy Heiler wrote: > > On Sat, Jul 13, 2013 at 10:49 PM, Daniel Dinnyes > > > wrote: > > (->>> "test-strin

Re: --> macro proposal

2013-07-13 Thread Daniel Dinnyes
Hey guys, I just came up with some good shit, check this out! (defmacro ->>> ([x] x) ([x alias form] `(let [~alias ~x] ~form)) ([x alias form & more] (let [y `(->>> ~x ~alias ~form)] `(->>> ~y ~@more (->>> "test-string-with-lots-of-dashes" x (s/split x #"-")

Re: S-s-s-serious performance bug with `map` laziness

2013-07-13 Thread Daniel Dinnyes
/questions/4290665/does-concat-break-the-laziness-of-line-seq http://stackoverflow.com/questions/16194841/clojure-lazy-sequences-in-math-combinatorics-results-in-outofmemory-oom-error/16270113#16270113 On Sunday, July 14, 2013 2:33:56 AM UTC+1, Daniel Dinnyes wrote: > > Hiya, check this code ou

S-s-s-serious performance bug with `map` laziness

2013-07-13 Thread Daniel Dinnyes
Hiya, check this code out guys: (defn point [x y] (println "x:" x "y:" y) [x y]) (defn gen-data [n m] (for [i (range n)] (for [j (range m)] (point i j (def data (apply concat (gen-data 100 100))) (nth data 5) "The output was the following:" "x: 0 y: 0 x: 0 y: 1 x: 0

Re: --> macro proposal

2013-07-13 Thread Daniel Dinnyes
Hiya, There the main arguments are 99% of the times the first or the last ones. > So -> or ->> will work. > Just made a quick search on `main arguments` on both Google and Wikipedia. Do you mean the arguments in `public static void main (String[] args)`? If not please provide some definition wh

Re: [ANN]: Introducing lein-try

2013-07-13 Thread Daniel Dinnyes
exception handling or something. On Sunday, July 14, 2013 12:58:51 AM UTC+1, Daniel Dinnyes wrote: > > Looks promising though. Pomegranate is significantly more complex, and I > could never remember the name of the function which dynamically loads the > libs. > > On Sunday, July 14

Re: [ANN]: Introducing lein-try

2013-07-13 Thread Daniel Dinnyes
Looks promising though. Pomegranate is significantly more complex, and I could never remember the name of the function which dynamically loads the libs. On Sunday, July 14, 2013 12:55:55 AM UTC+1, Daniel Dinnyes wrote: > > Well, that's the most convenient way it should work anyway,

Re: [ANN]: Introducing lein-try

2013-07-13 Thread Daniel Dinnyes
Well, that's the most convenient way it should work anyway, just a list of key, value, key, value, key, value argument list. Easy to implement. Accepting brackets is criminal. On Saturday, July 13, 2013 6:13:21 PM UTC+1, Steven Degutis wrote: > > I think it also works with just: lein try clj-tim

bug in clojure.zip/node implementation

2013-01-10 Thread Daniel Dinnyes
Hi, I am trying to navigate an XML structure using the clojure.contrib.zip-filter.xml library, but for some strange reason I receive the following exception: ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IFn clojure.zip/node (zip.clj:67) Here is an example which demo

Re: core/group-by with optional value-mapper function

2012-12-17 Thread Daniel Dinnyes
ce for the value-mapper is as an optional parameter for `group-by` itself. What do you think? Cheers, Daniel On Monday, December 17, 2012 10:13:17 AM UTC, Daniel Dinnyes wrote: > > Hi, > > I expect the cost of calling `identity` to be negligible. Not for sure, > but the JVM might

Re: core/group-by with optional value-mapper function

2012-12-17 Thread Daniel Dinnyes
does the `identity` effect performance? I wouldn't think much. > > Alex > > On Fri, Dec 14, 2012 at 9:58 AM, Daniel Dinnyes > > > wrote: > >> Hi, >> >> I would like to suggest an enhancement to the clojure.core/group-by >> function. The ide

core/group-by with optional value-mapper function

2012-12-14 Thread Daniel Dinnyes
uot; "Rex"]} (group-by :type #(.toUpperCase (:name %)) animals) ; hell yeah! > {:cow ["BETSY"], :cat ["MURMUR" "ROSIE" "ALF"], :dog ["LESSIE" "DINGO" "REX"]} It would be so cool to have this in the core. What do you gu