http://www.cs.cmu.edu/~rwh/smlbook/online.pdf expression : type 3*6 + 2 : int --- Types: real Operations: +, -, *, /, =, <, ... char Operations: ord, chr, =, <, ... string Operations: ^, size, =, <, ... bool Operations: if exp then exp1 else exp2 not exp ... == 3+3.14 não pode. == real(3) + 3.14 pode == 3 + round(3.14) pode div é operador para inteiros / é operador para floating point if exp then exp1 else exp2 exp deve ser bool. exp1 e exp2 devem ter tipos iguais. ==Type Binding== ... ==Value Bindings== uma variável assume o valor atribuído para sempre. "binding is not assignment. The binding of a variable never changes; once bound to a value, it is always bound to that value(within the scope of the binding)." val m : int = 3+2 val pi : real = 3.14 and e : real = 2.17 Sintaxe: val var1 : typ1 = exp1 and ... and varn : typn = expn val x : float = Math.sin pi (x assumirá 0.0) ==Limiting Scope== val m : int = 2 val r : int = let val m : int = 3 val n : int = m*m in m*n end * m [r recebe 54] Sintaxe: let declarações in expressão (retorno) end ==Functions== Function application is indicated by juxtaposition: we simply write the argument next to the function. fn var : typ => exp typ é o tipo da entrada Exemplo (Uma função sem nome (lambda)) (fn x : real => Math.sqrt (Math.sqrt x)) (16.0) irá retornar a raiz quarta de 16. Outra forma: val fourthroot : real -> real = fn x : real => Math.sqrt (Math.sqrt x) fourthroot 16.0 irá retorna a raiz quarta de 16. a variavel fourthroot tem type real->real (uma função que recebe real e retorna real) Há um jeito mais resumido de dar um nome a uma função. fun fourthroot (x:real):real = Math.sqrt (Math.sqrt x)