zoukankan      html  css  js  c++  java
  • Difference between LET and LET* in Common LISP

    Difference between LET and LET* in Common LISP
     
    LET
     
    Parallel binding which means the bindings come to life at the same time and they do not shadow each other. The values are effective inside LET and they are undefined outside LET. Just like local variables.
     
    LET binds variables all at the same time.
     
    None of the variables defined in the LET have a value after lisp has finished evaluating the form.
     
    Example 1:
     
    Input:
    * (setf x 'outside)
    * (let ((x 'inside)
            (y x))
            (list x y))
     
    Output:
    (INSIDE OUTSIDE)
     
    Example 2:
     
    Input:
    (let ((a 3)
          (b 4)
          (c 5))
         (* (+ a b)c))
     
    Output:
    35
     
    Example 3:
     
    Input:
    (setq a 10)
    (let ((a 3)
          (m a))
         (+m a))
     
    Output:
    13
     
     
     
     
    LET*
     
    Sequential binding.
     
    Example:
     
    Input:
    * (setf x 'outside)
    * (let* ((x 'inside)
             (y x))
             (list x y))
     
    Output:
    (INSIDE INSIDE)
     
     
     
    It always more efficient to use LET than LET*. Since the program can run parallel when using LET.
  • 相关阅读:
    eclipse使用
    模板模式

    异常处理
    内部类
    面向对象三大特征(三)--多态
    java双指针的简单理解
    简单易懂回溯算法
    《深入理解Java虚拟机》之(一、内存区域)
    Java笔记(第七篇 JDBC操作数据库)
  • 原文地址:https://www.cnblogs.com/johnpher/p/3404569.html
Copyright © 2011-2022 走看看