[Haskell-cafe] An interesting curiosity
minh thu
noteed at gmail.com
Thu Sep 18 15:21:47 EDT 2008
2008/9/18 Evan Laforge <qdunkan at gmail.com>:
>> All of this works of course because in Haskell, "=" is not an assignment,
>> it's a definition, and the RHS is not a variable, it's a pattern. And "4" is
>> a perfectly legitimate pattern. Now, if only I could find a use for all this
>> that borders on "useful"...! ;-)
>
> I like this one:
>
> let {1 + 1 = 3; 3 + 1 = 3} in 1 + 1 + 1
>
> Right answer, for the wrong reasons. Useful? Well... does confusing
> people count as useful?
Well, Andrew says it himself : it's practical because you can pattern
match against specific value :
f [] = ...
f (4:xs) = ...
f (x:xs) = ...
Thu
More information about the Haskell-Cafe
mailing list