views:

25

answers:

1

Hi, I installed the sml interpreter from here : http://www.smlnj.org/, I used the self extracting .EXE for windows. (I'm running windows7 64 bit)

Although simple operations on basic datatypes are working, it is not recognising operations on arrays/vectors (update, array constructor etc). Do i need to install something else as well to make it work?

Maybe there's a problem in my understanding of the syntax, could someone provide an example code which say declares an array of length 10, initialized to 0 and then adds 1 to each value?

noob alert

Thanks

A: 

Try the following in SML/NJ:

- Vector.map (fn (a) => a+1) (Vector.tabulate (10, fn (a) => 0));
val it = #[1,1,1,1,1,1,1,1,1,1] : int vector

The operations on vectors are available here: http://www.standardml.org/Basis/vector.html#Vector:STR:SPEC And the #[...] notation works for creating vectors, as well.

Lars Bergstrom