Hacker News new | ask | show | jobs
by theophrastus 4508 days ago
what does this nicer non-spaghetti do?

chunkWith :: ([a] -> ([a], [a])) -> [a] -> [[a]]

chunkWith _ [] = []

chunkWith f xs = let (h, t) = f xs in h : chunkWith f t

i'm sure that many here merely glance at that and understand it immediately. but as i typed above, it somehow makes me feel bad about my own stupidity. (no need for anyone to explain specifically what this tiny example does, (i actually happen to understand this one). the goal here is to admire the immediate obviousness of the syntax ;))