Reputation: 1096
i wrote a function to find the position of the next column of an asciibox
for instance :
+-----++---++---+
| a || b || c |
+-----++---++---+
box b should start at column "pseudo code " {length (box a)} and box c should start at pseudo code {length box a + length box b}
so i wrote this function
f:: [Int]->[Int]->[Int]
f (x:xs) [] = f xs [x]
f [] ys = ys
f (x:xs) ys = f xs (ys++[x+ last ys])
which gives me what i want
f [23,24,25] []
ghci> [23,47,72]
i would like to know if other algorithm is possible . Is there any solution with "fold" or "unfold" or perhaps "iterate"
thanks
Upvotes: 1
Views: 100