Hi
I am a newbie to the realm of functional programming and have just started learning Scheme (though it is a semi-functional programming language). I did some tutorials on lists which is well supported in Scheme. I was wondering whether Scheme has support for fiddling with arrays ?
Or do I need to define my own data type ? Lists are an inductively defined data types. If I'm to define arrays as a new data type then can it be defined inductively ?
Please help. Thanks in advance.
cheers
-
You're looking for vector.
(define arr (vector 1 2 3)) (define arr #(1 2 3))Andriyev : Thanks for introducing me to the notion of vector in scheme. I just looked up for it and it seems, one can do a look up in constant time (just like in arrays). Also, it seems to be a data type fixed in space - much like an array. cheers -
Arrays are not very "functional". That's why they are not as important as lists in a functional language like Scheme.
I don't think you can define arrays inductively.
-
Hi,
you can represent arrays using vectors. The vectors in Scheme are not functional in the sense that you can mutate them (using vector-set!). However, also lists can be mutated using set-car! and set-cdr!.
0 comments:
Post a Comment