okay, i started reading on haskell when i'm not reading SICP. haskell is also functional PL, so i'm not really losing focus alternating them. so second basic data structure in haskell is tuple(first being list, of course). it's an immutable set of object with the same type(types do play a major role in HS).
and tuple of 2 elements(pair) is of different type, than tuple of 3(triple) or more elements. there's a shortcut to get values from pair fst(1,2) == 1, snd(1,2) == 2.
but guess what, they ain't workin' on tuples of other sizes! not sure i'm following the logic of HS creators yet :)
so why i mentioned lisp - it's main data structure is list(no surprises, it's called LISt Processing after all). lists there are actually "linked lists", first element can be accessed as "car(list)", and rest of the list is "cdr(list)". so "car(cdr(list))" is a second element of the list. there's even a shortcut for it - "cadr".
and you can stuff any number of "a"'s or "d"'s there, to get the needed element(or list tail), "cdddr(list)" is "all list elements starting from fourth".
no limitations for lists of size 2! :)
Sunday, January 6, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment