Skip to content

Instantly share code, notes, and snippets.

import Control.Monad.State
import System.Random
first lst = first' lst [] []
first' [] _ result = reverse result
first' (h:t) found result =
if any (== h) found then first' t found (False:result)
else first' t (h:found) (True:result)