On Jun 2, 7:55 am, Andrew Wagner wrote:
> > You can use destructuring in your predicate's arg list:
>
> Not to hijack the thread but...is there some reason clojure doesn't just
> just call this pattern-matching? Is it different somehow?
Pattern matching matches not only structure but also value
> Not to hijack the thread but...is there some reason clojure doesn't just
> just call this pattern-matching? Is it different somehow?
I guess the simplest answer is "because it's destructuring, not
pattern-matching" :)
As Rich explained in the thread to which Stephen linked, pattern
matching (a
Wilson MacGyver writes:
Hi Wilson,
> I saw that clojure has loop. But in other functional languages, using
> loops are always discouraged. So I didn't know if loop was the
> "clojure" idiomatic way of doing this.
Clojure's `loop' (with `recur') is no "real" loop in an imperative
sense. It's
I see. very clever. I'm not used to loop constructs with
no side effect.
On Tue, Jun 2, 2009 at 12:21 PM, Konrad Hinsen
wrote:
>> I saw that clojure has loop. But in other functional languages,
>> using loops are always discouraged. So I didn't know if loop
>> was the "clojure" idiomatic way of
The same is true of irrefutable patterns in haskell.
>
> The difference is that a pattern match can fail, and in that case
> other patterns are tried. Clojure's destructuring assumes that the
> value has the right structure. If it doesn't, then you will get an
> exception thrown.
>
>
--~--~-
On 02.06.2009, at 18:00, Wilson MacGyver wrote:
> actually I had the exact same reaction. So I'd echo Andrew's comment.
> Is this different than pattern-matching in say haskell/scala?
The difference is that a pattern match can fail, and in that case
other patterns are tried. Clojure's destruct
On Jun 2, 2009, at 11:55 AM, Andrew Wagner wrote:
Not to hijack the thread but...is there some reason clojure doesn't
just just call this pattern-matching? Is it different somehow?
This thread has some info on that:
http://groups.google.com/group/clojure/browse_frm/thread/0aa57ab265f7474a
>
> Why doesn't Ruby just call it destructuring like Lisp has been doing
> for decades? ;)
>
> So that non-academics have a prayer at not getting scared away by an
unnecessarily-technical name?
--~--~-~--~~~---~--~~
You received this message because you are subscri
On Tue, Jun 2, 2009 at 6:02 PM, Michael Wood wrote:
> On Tue, Jun 2, 2009 at 5:55 PM, Andrew Wagner wrote:
>>> You can use destructuring in your predicate's arg list:
>>
>> Not to hijack the thread but...is there some reason clojure doesn't just
>> just call this pattern-matching? Is it differe
On Tue, Jun 2, 2009 at 5:55 PM, Andrew Wagner wrote:
>> You can use destructuring in your predicate's arg list:
>
> Not to hijack the thread but...is there some reason clojure doesn't just
> just call this pattern-matching? Is it different somehow?
Why doesn't Ruby just call it destructuring li
I saw that clojure has loop. But in other functional languages,
using loops are always discouraged. So I didn't know if loop
was the "clojure" idiomatic way of doing this.
On Tue, Jun 2, 2009 at 11:52 AM, Konrad Hinsen
wrote:
>> My first reaction was to do it using a sequence. Is this the clojur
Ditto what everyone else said, plus let's get rid of the duplicated
call to Math/log by splitting the iterate into an iterate + a map:
(take-while
(fn [[_ second]] (< second 10))
(map (fn [x] [x (/ x (Math/log x))])
(iterate #(* % 2) 2)))
Stu
>
> On 02.06.2009, at 17:35, Wilson
actually I had the exact same reaction. So I'd echo Andrew's comment.
Is this different than pattern-matching in say haskell/scala?
On Tue, Jun 2, 2009 at 11:55 AM, Andrew Wagner wrote:
>> You can use destructuring in your predicate's arg list:
>>
>
> Not to hijack the thread but...is there som
ah, got it. thanks!
On Tue, Jun 2, 2009 at 11:48 AM, Stephen C. Gilardi wrote:
>
> On Jun 2, 2009, at 11:35 AM, Wilson MacGyver wrote:
>
>> what I like to know is, how do I filter for with value b is < X
>
>
> You can use destructuring in your predicate's arg list:
>
> (filter (fn [[_ x]]
On Tue, Jun 2, 2009 at 5:35 PM, Wilson MacGyver wrote:
>
> Apologies in advance on a very newbie question.
>
> I've constructed a sequence
>
> (take 10 (iterate (fn [[a b]] [(* 2 a) (/ a (Math/log a))]) [2 (/ 2
> (Math/log 2))])
>
> doing a take 10 on it, produce the pairs I expect.
>
> what I li
>
> You can use destructuring in your predicate's arg list:
>
>
Not to hijack the thread but...is there some reason clojure doesn't just
just call this pattern-matching? Is it different somehow?
--~--~-~--~~~---~--~~
You received this message because you are subscr
On 02.06.2009, at 17:35, Wilson MacGyver wrote:
> for example, the first 10 produces.
>
> ([2 2.8853900817779268] [4 2.8853900817779268] [8 2.8853900817779268]
> [16 3.8471867757039027] [32 5.7707801635558535] [64 9.233248261689365]
> [128 15.38874710281561] [256 26.380709319112476] [512
> 46.166
On Jun 2, 2009, at 11:35 AM, Wilson MacGyver wrote:
what I like to know is, how do I filter for with value b is < X
You can use destructuring in your predicate's arg list:
(filter (fn [[_ x]] (< x 10)) *1)
In English, the function takes an argument which can be accessed
sequentia
Apologies in advance on a very newbie question.
I've constructed a sequence
(take 10 (iterate (fn [[a b]] [(* 2 a) (/ a (Math/log a))]) [2 (/ 2
(Math/log 2))])
doing a take 10 on it, produce the pairs I expect.
what I like to know is, how do I filter for with value b is < X
for example, the f
19 matches
Mail list logo