Haskell | Racket | notes |
---|---|---|
null | null? or empty? | not to be confused with null/empty |
map, zipWithN | map | Haskell's map is just zipWith1, after all |
length | length | |
length . filter | count | |
filter | filter | |
filter . not | filter-not | also, negate can be used to inverse a predicate |
lookup | assoc | |
foldr | foldr | |
foldl | foldl | |
all | andmap | polyvariadic |
any | ormap | polyvariadic |
head | car or first | |
(!! 1) ... (!! 9) | second ... tenth | aka cadr, caddr, cadddr and caddddr |
!! | list-ref | clumsy name hints that it isn't needed very often |
tail | cdr or rest | |
: | cons | since lists are tuples, it's also , |
last | last | not in racket/base |
reverse | reverse | |
intersperse, intercalate | add-between | |
permutations | permutations | |
++ | append | |
concat | append* | deep version of concat is called flatten |
sum | apply + | |
product | apply * | |
maximum | apply max | |
minimum | apply min | |
maximumOn | argmax | |
minimumOn | argmin | |
replicate | make-list | |
take | take | there's also take-right |
drop | drop or list-tail | |
takeWhile | takef | |
dropWhile | dropf | |
splitAt | split-at | |
span | splitf-at | |
elem | member | that's where everything-but-#f-is-true proves useful |
find | memf | |
partition | partition | |
nub[By,On] | remove-duplicates | controlled with optional arguments |
delete | remove | |
sort[By,On] | sort | |
mapM_ | for-each | |
list ranges | range | |
random shuffle | shuffle |
Last active
January 30, 2016 15:12
-
-
Save khafatech/42b25c8891565cf9f761 to your computer and use it in GitHub Desktop.
racket-haskell-list-functions from https://artyom.me/learning-racket-1#interlude-list-functions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment