[e-lang] Couple of newbie questions
Chris Rathman
Chris.Rathman at tx.rr.com
Wed Dec 27 12:29:40 CST 2006
Chris Rathman wrote:
> Mark S. Miller wrote:
>
>> Shouldn't the first return in your
>>
>> def list(xs) {
>> if (xs.size() == 0) {
>> return [nil]
>> } else if (xs.size() == 1) {
>> return cons(xs[0], nil)
>> } else {
>> return cons(xs[0], list(xs(1)))
>> }
>> }
>> be
>> return nil
>>
On second thought, you are correct here insofar as it makes for a more
concise encoding. I fixed the translation as suggested. The encoding
now looks like:
nil => nil
3|nil => [3, nil]
2|3|nil => [2, [3, nil]]
1|2|3|nil => [1, [2, [3, nil]]]
Thanks,
Chris Rathman
More information about the e-lang
mailing list