As Andy Fingerhut pointed out, since (hash [a b]) is 31*(a + 30) + (b + 31)
when a and b are ints, summing the hashes of 2-tuples when the values are
small ints, as happens when hashing sets of such 2-tuples, is quite likely
to lead to collisions. This particular problem could be avoided by
spr
The let? macro addresses such
situations: https://github.com/egamble/let-else
--
--
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
Version 1.0.1 of the let? macro adds the :is keyword.
The let? macro is on github at https://github.com/egamble/let-else and
on clojars at https://clojars.org/egamble/let-else.
I've found let? very useful in replacing nested lets, when-lets, if-
lets, whens, and ifs with a single let form. It all
Another way to flatten nested lets and conds is to use a macro that
lets you insert conditionals in your lets (vs. your suggestion of
inserting lets in conds).
I wrote a let? macro that does that: https://github.com/egamble/let-else
- Evan
On Mar 7, 10:51 pm, Mark Engelberg wrote:
> In the mea
ond [a x b (* a 4)]
> (> b x) 1
> :else 2)
>
>
>
>
>
>
>
> On Thursday, March 8, 2012 9:01:33 AM UTC-8, Evan Gamble wrote:
>
> > Another way to flatten nested lets and conds is to use a macro that
> > lets you insert conditionals in your lets (vs. y
ucklehead" macro is a bit weak, since there have been many other
similar macros.
...and I have learned to love nil, even the :else nil clause that
repels you.
- Evan
On Mar 9, 9:26 am, Craig Brozefsky wrote:
> Evan Gamble writes:
> > (let? [a foo :else nil
> >
On Mar 9, 11:13 am, daly wrote:
> There is a bit of brain-training necessary to read code with
> parens but not a lot. In fact, my editor can read paren code.
Hard to see what your point is there. I didn't write let? because I
can't read code with parens. I've been writing Lisp since 1983,
star
On Mar 10, 12:19 am, Craig Brozefsky wrote:
> Sure, you feel your defmacro, oats you write some ghetto macros with
> syntactically significant keywords, maybe stay up late a few nights
> expanding it into a some monstrosity and suddenly you have loop (I don't
> think CL's format is in the same r
If if-let and when-let don't get support for multiple bindings, you could
try https://github.com/egamble/let-else .
On Tuesday, May 15, 2012 12:09:08 PM UTC-7, Hubert Iwaniuk wrote:
>
> I tried using if-let with multiple binding in past as well.
> Following least surprise principle, I would like
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
For the situation where the lets are nested because you're checking the
values in some way after each binding, I wrote a macro called let?. I find
it very useful and use it in nearly all my
code. https://github.com/egamble/let-else
--
You received this message because you are subscribed to the
I noticed in my code that I often nest a let inside an if-let, or vice-
versa, so I wrote a macro let-else that expands into nested lets,
except where there's an :else after a binding, in which case
that binding expands into an if-let.
E.g.
(let-else
[foo (f1) :else (e)
bar (f2)]
(b1)
(
> z)
>
> ;; expands to
>
> (let [x 100
> y 300]
> (when (pos? y)
> (let [z (- y 250)]
> z))) ;; => 50
>
> ;; and returns 50. The following returns nil:
>
> (let? [x 100
>
> y 300
>
> :ensure (neg? y)
>
> z (-
fnparse has been forked by John Poplett and updated to work with
clojure 1.3.
On Clojars it's at https://clojars.org/org.clojars.jpoplett/fnparse.
On Github it's at https://github.com/John-Poplett/fnparse
- Evan
On Jan 28, 7:19 am, Roman Perepelitsa
wrote:
> I'm looking for a parser generator
14 matches
Mail list logo