Skip to content

Instantly share code, notes, and snippets.

@BinRoot
Created April 20, 2013 05:29
Show Gist options
  • Select an option

  • Save BinRoot/5424869 to your computer and use it in GitHub Desktop.

Select an option

Save BinRoot/5424869 to your computer and use it in GitHub Desktop.
import Data.List
main = do
print "hi"
list1 = ["aa", "bb", "cc"]
list2 = ["bb", "cc"]
getMatches list1 list2 = getMatches' (check list1 list2) list2
getMatches' indices list2 = map (f list2) (filter (>=0) indices)
f list2 x = list2 !! x
check list1 list2 = map getTheIndex (check' list1 list2)
getTheIndex (Just a) = a
getTheIndex Nothing = -1
check' [] list2 = []
check' list1 list2 = (elemIndex (head list1) list2) : (check' (tail list1) list\
2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment