Skip to content

Instantly share code, notes, and snippets.

@orionll
Last active December 26, 2015 09:49
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 orionll/7131981 to your computer and use it in GitHub Desktop.
Save orionll/7131981 to your computer and use it in GitHub Desktop.
How ML code looks like with tabs
fun all_except_option(str, lst) =
case lst of
[] => NONE
| x :: xs =>
if same_string(str, x)
then SOME xs
else case all_except_option(str, xs) of
NONE => NONE
| SOME xs' => SOME (x :: xs')
fun get_substitutions1(substitutions, s) =
case substitutions of
[] => []
| lst :: tail => case all_except_option(s, lst) of
NONE => get_substitutions1(tail, s)
| SOME lst' => lst' @ get_substitutions1(tail, s)
@cypok
Copy link

cypok commented Oct 24, 2013

My:

fun all_except_option(str, lst) =
  case lst of
    [] => NONE
  | x :: xs =>
      if same_string(str, x)
      then SOME xs
      else case all_except_option(str, xs) of
             NONE => NONE
           | SOME xs' => SOME (x :: xs')

fun get_substitutions1(substitutions, s) =
  case substitutions of
    [] => []
  | lst :: tail => case all_except_option(s, lst) of
                     NONE => get_substitutions1(tail, s)
                   | SOME lst' => lst' @ get_substitutions1(tail, s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment