4 ms·
For fun mostly but it can be useful too: it can find neat solutions I couldn't think of and I may decide to use it. Of course it gives also crazy stuff like `((
by rnhmjoj 10y ago
For fun mostly but it can be useful too: it can find neat solutions I couldn't think of and I may decide to use it. Of course it gives also crazy stuff like `(((.) . (,)) .)` that I will never put in a program because I don't understand or it's just worse than the original input.
- JadeNB 10y ago> For fun mostly but it can be useful too: it can find neat solutions I couldn't think of and I may decide to use it. Of course it gives also crazy stuff like `(((.) . (,)) .)` that I will never put in a program because I don't understand or it's just worse than the original input. If it is purely an intellectual exercise, to see how else the code could theoretically be written, then I totally see the point. (I am a mathematician, after all!) On the other hand, if it is code that you actually use in production, then surely the old dictum that I will misquote, for want of looking it up, as "if you write the cleverest code possible, then you are not clever enough to debug it", applies all the more so to say "if you aren't clever enough to write your own code, then you certainly aren't clever enough to debug it"! (Not you personally, I mean; just a comment on programmer-facing auto-generated code.)
- posterboy 10y agoI think the lesson here is, if the conversion looks horrendous, then the original was questionable in the first place.
- JadeNB 10y agoIncidentally, I couldn't resist some eta expansion. If I didn't screw it up: (((.) . (,)) .) f x g y (((.) . (,)) . f) x g y (((.) . (,)) (f x)) g y ((.) ((,) (f x))) g y ((.) (f x,)) g y ((f x,) . g) y (f x, g y)
- evincarofautumn 10y agoI wish the pointfree utility would use slightly higher-level combinators like those from Control.Arrow. Readable point-free code tends to break things up into many small reusable pieces, following the maxim of “name code, not data”. This example is totally absurd, since you’d just write “(f x, g y)” and call it a day, but you can extract a fully point-free version that’s somewhat readable. f = pairwise $ curry $ apply *** apply where pairwise = fcurry fcurry fcurry = fmap curry apply = uncurry ($)