Created
March 7, 2014 09:43
-
-
Save abhijith/9408564 to your computer and use it in GitHub Desktop.
Pattern matching differences between ocaml and erlang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(foo). | |
-export([drop/2]). | |
drop([], Elem) -> []; | |
drop([Elem|T], Elem) -> drop(T, Elem); | |
drop([H|T], Elem) -> [H | drop(T, Elem)]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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