Skip to content

Instantly share code, notes, and snippets.

-- Index based list operations using folds
--
-- Author: Umair Saeed
-- Date: 05/17/2015
--
-- insert at an index, implemented via foldr
insertAt :: a -> [a] -> Int -> [a]
insertAt x ys n = foldr insertHelper [] $ zip [0..] ys
where