in reply to (almost) foldl
Well, in unary, summing is as simple as concatenating. And Perl has a built-in decimal-to-unary converter (the x operator), as well as a built-in unary-to-decimal converter (the length function). Putting all this together:
But your implementation sure is fun :-) EDIT: Look at tye's code instead. This one is stupid. Don't know what I had in mind when I wrote 'length join "", '.my @list = (1, 2, 3, 4, 5); print length join "", map{"1" x $_} @list; #prints 15
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: (almost) foldl (""=>())
by tye (Sage) on Jun 08, 2011 at 02:24 UTC | |
Re^2: (almost) foldl
by dk (Chaplain) on Jun 08, 2011 at 04:56 UTC | |
by tye (Sage) on Jun 08, 2011 at 19:45 UTC | |
by Grimy (Pilgrim) on Jun 08, 2011 at 20:48 UTC | |
by Grimy (Pilgrim) on Jun 08, 2011 at 10:07 UTC |
In Section
Obfuscated Code