3 ms·
I'm a Haskell beginner. But this is my attempt at solving your algo functionally in Haskell. Note there's no shared state. fn ("a":lines') = fn (skip2 lines')
by ecthiender 10y ago
I'm a Haskell beginner. But this is my attempt at solving your algo functionally in Haskell. Note there's no shared state.
fn ("a":lines') = fn (skip2 lines')
fn (l:lines') = (parseLine l) : fn lines'
skip2 = tail . tail
Gave spaces above for readability. The function "fn" pattern matches "a", then skips 2 elements of the array and recursively calls itself.
Haskell programmers can correct if the program is correct/sound. I just wrote this from my mind. Not near any computer now.
- ecthiender 10y agoOops forgot to add the base condition to the recursion: fn [] = []