|
|
nemesis wrote:
> Invisible <voi### [at] devnull> wrote:
>> (g,s) = (\x -> x, \x -> x*x)
>>
>> That last line is the best. I didn't even realise you could *do* that!
>
> yes! very cool! Looks like Perl/Python 2 way assignment, but of course there's
> no assignment here, it's 2 functions defined in the same line by 2 tuples!
> Haskell is amazing...
I should have realised that this was possible - I've just never seen it
at the top-level before.
It's kinda nice to be able to write things like
(a',b',c',d') = (b,c,d,a)
to do a rotation. All those C programmers are sitting there defining
temporary variables to handle the shuffle, while I can just tell the
compiler exactly what I want the end result to be, and it just does it...
Interestingly, the compiler infers some rather strange types for those
functions. Clearly \x -> x is id, yet the compiler infers a less general
type than this - presumably due to the tupling. Or perhaps to the other
call sites in the program, I'm not sure...
>> Very odd...
>>
>> Right, so, let's do some analysis here.
>
> man, just run this madness and see what it does...
And how do you suggest I do that, given that there's no obvious "entry
point"?
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|