Re[Haskell-cafe] : Help with generalizing function
leledumbo_cool at yahoo.co.id
Mon Jun 23 07:03:18 EDT 2008
>> Don't give up so fast !! (Note that you can't do what you asked for in
>> Pascal either, in fact Pascal don't support n-uplet)
I'm not going to use n-uplet, dynamic array of array of Byte is enough.
Though not very optimizing, I can use 2 step process:
1. Generate all lists (array of Byte) of length N which each element ranges
from 0 to C.
2. Filter which has sum=C.
>> seems that leledumbo found a new way to force us give the answers to
>> those homeworks LOL
Don't worry, I'm not gonna use it because it has to be done in procedural
way (I haven't taken Functional Programming class yet). The reason why I ask
is I'm HOPING that if I can understand how it works, implementing the
procedural form would be easy. I've read somewhere that functional language
can be implemented in procedural one. In fact, GHC outputs C code.
Thanks for the answer. I'll use it to learn, it's quite difficult to switch
from procedural to functional. I mean, in procedural it's easy to find the
fastest solution using brute force. This can't be done in functional.
View this message in context: http://www.nabble.com/Help-with-generalizing-function-tp18063291p18066860.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe