학교/CPL16 Lecture 5: Functions, Substitution and Environments 목차 Learning Objectives• Explain how function application works by substituting parameters for arguments • Execute simple programs involving lambdas • Explain what name shadowing and name capture is • Implement recursion using only lambdas • Explain how environments are delayed substitutions Functions in ParetExamples Syntax (Lab/Extended) Example Example Function ApplicationParentheses aro.. 2024. 3. 28. CPL 2-3: Higher Order Functions 목차 Abstract Syntax Tree (ASTs) context-free syntax Expr.NumExt = INT // integer literals Expr.TrueExt = [true] Expr.FalseExt = [false] Expr.IdExt = ID Expr.UnOpExt = [([UnOp] [Expr])] Expr.BinOpExt = [([BinOp] [Expr] [Expr])] UnOp.MIN = [-] UnOp.NOT = [not] UnOp.HEAD = [head] UnOp.TAIL = [tail] UnOp.ISNIL = [is-nil] UnOp.ISLIST = [is-list] BinOp.PLUS = [+] BinOp.MULT = [*] BinOp.MINUS = [-] BinO.. 2024. 3. 27. Lecture 4: Functions 목차 Learning Objectives- Explain what a higher-order function is; motivate usefulness- Explain what a lambda(λ) is; motivate usefulness- Explain the difference between val and def in Scala- Write simple programs involving lambdas- Explain how function application works by substituting parameters for arguments- Execute simple programs involvnig lambdas Why Higher-Order Functions?Higher-Order Func.. 2024. 3. 27. CPL 1-2: Semantics and Transformations 목차 Translating from Java to Paret Example 1) Example 2) Example 3) Example 4) Mandatory Assignment desugar takes an abstract syntax tree (ExprExt) as input, and returns a core syntax tree (ExprC). interp takes a core syntax tree (ExprC) as input, and returns a value (Value). 1. Basics desugar: case TrueExt() => TrueC() case FalseExt() => FalseC() case NumExt(n) => NumC(n) case NilExt() => NilC().. 2024. 3. 26. 이전 1 2 3 4 다음 반응형