A different kind of solution is used here, based on J from .
Using:
[-1,2,0] `from` ["fran","world","san","hello"]
which returns: [Just "hello",Just "san",Just "fran"]
Definition after import List exposing (..) :
get idx lst = -- get an element from a list (negative indexes from end) if idx >= 0 then head (drop idx lst) else head (drop (negate (idx+1)) (reverse lst)) from idxs lst = -- atoms of idxs are indexes into lst case idxs of hd::tl -> (get hd lst)::(from tl lst) _ -> []
source share