On 22 March 2012 01:13, Solomon Foster <colo...@gmail.com> wrote:
> It actually smartmatches whatever is on the right hand side against
> the sequence, and stops when the smartmatch returns True.  It just
> "happens" that you smartmatch an anonymous function, it executes the
> function and returns its result.

I see... I still find this a little confusing. The idea of
smart-matching a function just doesn't quite fit with my brain. I can
memorize the fact that smart-matching 7 and &foo means evaluating
foo(7) and seeing if the value is true, but I can't say I "understand"
it.


> Examples:
>
> 2, 5 ... 11 # smartmatch is true when you hit 11
> 2, 5 ... True # stop right away
> 2, 5 ... False # never stop
> 2, 5 ... * # shorter way of saying never stop
> 2, 1, 1/2 ... Num # stop when the number switches from a Rat to a Num
> 'a' ... /f/ # stop when the regular expression matches

Interesting.


Cheer,
Daniel.
-- 
I'm not overweight, I'm undertall.

Reply via email to