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.
  • 相关阅读:
    taglib
    ThinkPHP魔术方法
    给图片添加文字
    公益筹模板
    清空(数据库+文件夹)
    php——文件下载
    查询上一个tp语句
    安装wampserver 2.5的时候出现丢失MSVCR100.dll的解决办法。
    ThinkPHP3.2.3 安装教程
    java基础——File类的基本用法
  • 原文地址:https://www.cnblogs.com/johnpher/p/3404569.html
Copyright © 2011-2022 走看看