[Skip Navigation] [Remove Frame] [CS320] [Text Version] ml.functions.html Sat Dec 23 08:00:26 PST 2006

Contents


    A Quick List of Functions in SML/NJ

    Note

    Use "*" to show products "><" (*)::=(><).

    Arithmetic

  1. negation::int->int="~".
  2. negation::real->real="~".
  3. max::int*int->int.
  4. min::int*int->int.
  5. abs::int->int.
  6. abs::real->real.
  7. real::int->real.
  8. truncate::real->int.
  9. ceiling::real->int.
  10. floor::real->int.
  11. sin::real->real.
  12. cos::real->real.
  13. arctan::real->real.
  14. ln::real<>->real. (partial functions, not defined on zero or less)
  15. sqrt::real<>->real. (partial functions, not defined on zero or less)
  16. exp::real->real.
  17. chr::int->string.
  18. |-chr= /ord. --- chr inverts the effect of ord.
  19. makestring::int|real->string.
  20. print::int|real->unit.

    Comparisons

  21. =:: int*int->bool = (1st) has same value as (2nd).
  22. <>:: int*int->bool = (1st) is not equal to (2nd).
  23. <::int*int->bool.
  24. >::int*int->bool.
  25. <=::int*int->bool.
  26. >=::int*int->bool.

    Strings

    The characters in strings are numbered 0,1,2,... .

  27. explode::string->string list=each char in (_) becomes item in resulting list.
  28. implode::string list->string=concatenate elements of (_).
    (IE): implode o explode = Id.
    (EI): explode o implode = Id.
  29. size::string->int=number of characters in string.
  30. substring::string*int*int->string=(3rd) chars starting at (2nd) of string (1st).
  31. ord::string->int=number in character sequence of first char of (_).
  32. ordof::string*int->int.
  33. print::string->unit.

    Boolean

  34. andalso::bool*bool->bool.
  35. orelse::bool*bool->bool.
  36. not::bool->bool.
  37. makestring::bool->string.
  38. print::bool->unit.

    Lists

  39. hd::a' list -> a' for type a'.
  40. tl::a' list->a' list for type a'.
  41. nth::'a list*int->a'.
  42. nthtail::'a list*int->a' list.
  43. null::'a list->bool.
  44. length::'a list->int.
  45. rev::'a list->'a list.
  46. map::('a -> 'b) -> 'a list -> 'b list for 'a and 'b types.

    app, revapp:: ('a->'b)-> 'a list -> 'b list.

    fold, revfold:: (('a * 'b)->'b) ->'a list ->'b -> 'b.

  47. exists::('a->bool)->'a list-> bool.

    Arrays

    Must call
  48. open Array;
  49. array::int*'a -> 'a array.
  50. sub::'a array*int->'a.
  51. update::'a array * int * 'a -> 'a array.
  52. length::'a array->int.
  53. arrayoflist::'a list -> 'a array.

    References

  54. dereference::="!"::'a ref -> 'a.
  55. assignment::=":="::'a ref*'a->unit.
  56. inc::int ref->unit.
  57. dec::int ref->unit.

    Bit Strings

    andb,orb,xorb::int*int->int lshift,rshift::int*int->int.

    Byte arrays

  58. array::int*int->bytearray. sub, update, length as in arrays.

  59. extract::bytearray*int*int->string.

    fold, revfold.

    app,revapp.

    UNIX Based Functions

  60. use::string->unit=loads UNIX file name(_) relative to current working directory. Undefined side effects in expressions.

  61. execute::string*string list->instream*outstream=execute command with path name(1st) and arguments (2nd) and return ...??.

End