No point free definitions in let rec ?
Here is my example. It is about converting the a number to its English representation: 1002 -> one thousand two. And here is the relevant fragment of the code
and up_to_thousand n = upto 1000L 100L "hundred" up_to_million n
and up_to_million n = upto 1000_000L 1000L "thousand" up_to_billion n
and up_to_billion n = upto 1000_000_000L 1000_000L "million" up_to_trillion n
and up_to_trillion n = upto 1000_000_000_000L 1000_000_000L "billion" (fun _ -> assert false) n
and upto max factor word next = function (* more stuff *)
this works. But this
and up_to_thousand = upto 1000L 100L "hundred" up_to_million
and up_to_million = upto 1000_000L 1000L "thousand" up_to_billion
and up_to_billion = upto 1000_000_000L 1000_000L "million" up_to_trillion
and up_to_trillion = upto 1000_000_000_000L 1000_000_000L "billion" (fun _ -> assert false)
and upto max factor word next = function (* more stuff *)
does not. The only difference being, that the parameter n is removed from both sides in the second case. Just curious if this is limitation in the compiler or something more fundamental, which I'm missing
Posted Nov 5, 2016, 9:36 PM UTC
Can you give a complete working example code or error message?
Working code here - http://exercism.io/submissions/8d2a355950564a45875e07d205817798
remove the
nfrom both sides and it fails