4 ms·
Yes. oneTwo = 1 : 2 : oneTwo is a circular singly-linked list containing 1 and 2. If you wanted to change the 1 to a 4 though, you would not be able to do s
by quchen 13y ago
Yes.
oneTwo = 1 : 2 : oneTwo
is a circular singly-linked list containing 1 and 2. If you wanted to change the 1 to a 4 though, you would not be able to do so without creating an entire new list. You can use Vector or Array (i.e. fixed-size containers) to make yourself a circular buffer, but the implementation will be very similar to what you would do in C.
- cbsmith 13y agoWow. That looks hard. I bet you stayed up all night working on that. ;-) Seriously: sometimes things are hard because you don't know the language all that well. Consider that possibility.
- cbsmith 13y agoJust to be clear: the advice of "consider that possibility" is intended for the author of the article. quchen clearly knows the "easy" way to do this kind of thing with Haskell.