Skip to content

Instantly share code, notes, and snippets.

Created October 5, 2016 12:26
Show Gist options
  • Save anonymous/3b03d34cf38a3158a1fb931a7a8f60c7 to your computer and use it in GitHub Desktop.
Save anonymous/3b03d34cf38a3158a1fb931a7a8f60c7 to your computer and use it in GitHub Desktop.
let calc_len = function
| `Int x -> if x > 0 then 1 else -1
| `String y -> String.length y;;
let a = [`Int 1; `Int 2; `Int 3];;
let b = [`String "ali"; `String "veli"; `String "deli"];;
List.map a ~f:calc_len;;
List.map b ~f:calc_len;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment