Skip to content

Instantly share code, notes, and snippets.

@abhijith
Created March 7, 2014 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhijith/9408564 to your computer and use it in GitHub Desktop.
Save abhijith/9408564 to your computer and use it in GitHub Desktop.
Pattern matching differences between ocaml and erlang
-module(foo).
-export([drop/2]).
drop([], Elem) -> [];
drop([Elem|T], Elem) -> drop(T, Elem);
drop([H|T], Elem) -> [H | drop(T, Elem)].
let rec drop l elem =
match l with
| [] -> []
| hd :: tl when hd = elem -> drop tl elem
| hd :: tl -> hd :: drop tl elem
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment