#lang planet wrturtle/pyret/bsl # let statements fun det(a,b,c): let bsq = b*b, ac4 = a*c*4 in: bsq - ac4 # -8 det(1,2,3) # where statements -- semantically equivalent to let fun quad_roots(a,b,c): # Racket functions are still here, but with different syntax cons(root1, root2) where root1 = (-b + sqrt(det(a,b,c))) / (2 * a), root2 = (-b - sqrt(det(a,b,c))) / (2 * a) # (-2 . -3) quad_roots(1,5,6) # (1 . 1) quad_roots(1,-2,1) # let/where get mapped to local, so you don't need to bother teaching three # separate constructs (let, let*, letrec) fun foo(x): let y = x + 2, z = y + 4 in: x + y + z # 1 + (1 + 2) + ((1 + 2) + 4) = 1 + 3 + 7 = 11 foo(1)