Re:Fun with a Functional Programming Interview Question
by al2o3cr on Saturday February 06, 2021 @09:18PM
(#26052037)
Surprising that F# doesn't have a "chunkBy" function for sequences; it makes the solution in Elixir vastly more readable than the version in the article:
Re:Fun with a Functional Programming Interview Question
by zzo38computer on Sunday February 07, 2021 @02:45AM
(#26053399)
I did it this way:
map (head &&& length) . group
(Although in an actual full program, there would be other considerations (what considerations those are depends on the program being written), and in a full program I probably would not be using Haskell, but rather C.)
(set 'L '()) (dolist (s (explode "aaaabbbcca")) (if (!= (ref-all s L) '((0 0))) (push (list s 1) L) (inc (L 0 1)))) (print (reverse L))