fun makelist 0 = []
|makelist 1 = []
|makelist 2 = [2]
|makelist x = x::[makelist (x-1)];
max close but: type of (makelist n) is int list? rite? so if u say [makelist (x-1)] then u have int list list? so how can u put x on top of that?
also y do u need cases for 0 and 1 ? will they ever b reached?
----------
2nd there is no reson 2 write ur thing 4 a whole list: there is a function List.exists that will tell u if some func evaluate 'true' for any elem in a list. 4 example
fun isthree x = x = 3
List.exists isthree [1, 2, 3, 4, 5, 6]
that is true bacaeuse isthree on 3 is true !!!!
but
List.exists isthree [1, 2, 4, 5, 6]
that one is false !!!
can u use this to help ur program b easier???
|