lisp

What's the difference between write, print, pprint, princ, and prin1?

岁酱吖の 提交于 2019-11-29 02:48:46
问题 I'm getting into some Lisp, and I've come across various different functions that to me appear to be doing the same thing... Namely printing to console... So what exactly is the difference between all those different functions? 回答1: This is answered here: http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_pr.htm write is the general entry point to the Lisp printer. prin1 produces output suitable for input to read . princ is just like prin1 except that the output has no escape

How to process input and output streams in Steel Bank Common Lisp?

主宰稳场 提交于 2019-11-29 01:30:37
问题 I'm trying to figure out how to use the output stream of one program I start with RUN-PROGRAM so it can be used as the input of another program started with RUN-PROGRAM (i.e., the moral and perhaps literal equivalent of piping). I've tried using a number of combinations of the :INPUT , :OUTPUT and :WAIT keyword arguments, but nothing I've hit upon has been productive so far. Any tips would be helpful; for example, how would I go about doing something like ls | grep lisp from the shell? One of

want to learn common lisp [closed]

半城伤御伤魂 提交于 2019-11-29 01:18:13
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I have some basic python experience so I know the basics of programming such as variables, data types, functions and basic OO. What is

What are some examples of LISP being used in production, outside of AI and academia? [duplicate]

早过忘川 提交于 2019-11-29 01:16:10
问题 Possible Duplicate: Lisp in the real world A search query on Google reveals that the search term 'practical lisp' returns a link for Practical Common LISP, which is a very nice starter book. However, this is not what I was looking for or had in mind when I set out to search those terms. 回答1: EMACS is written in LISP ;-) 回答2: You're probably not going to get many useful answers, not because Lisp isn't widely used, but because nobody wants to reveal that they used Lisp, because: Lisp is their

let vs def in clojure

我的未来我决定 提交于 2019-11-29 00:58:15
I want to make a local instance of a Java Scanner class in a clojure program. Why does this not work: ; gives me: count not supported on this type: Symbol (let s (new Scanner "a b c")) but it will let me create a global instance like this: (def s (new Scanner "a b c")) I was under the impression that the only difference was scope, but apparently not. What is the difference between let and def ? Rayne The problem is that your use of let is wrong. Let works like this: (let [identifier (expr)]) So your example should be something like this: (let [s (Scanner. "a b c")] (exprs)) You can only use

What type of lambda calculus would Lisp loosely be an example of?

爱⌒轻易说出口 提交于 2019-11-29 00:06:14
问题 I'm trying to get a better grip on how types come into play in lambda calculus. Admittedly, a lot of the type theory stuff is over my head. Lisp is a dynamically typed language, would that roughly correspond to untyped lambda calculus? Or is there some kind of "dynamically typed lambda calculus" that I'm unaware of? 回答1: Lisp is a dynamically typed language, would that roughly correspond to untyped lambda calculus? Yes, but only roughly. In the "pure" untyped lambda calculus, everything is

clojure 新手指南(13):序列&向量

时间秒杀一切 提交于 2019-11-28 23:59:52
序列 我们知道clojure是Lisp的一种方言,那么这也意味着对这门语言必然植根于“列表解析”。但是在Clojure中,我们优先使用"序列"来创造列表和管理列表中的元素。 列表 之前我们说过,Lisp系列语言整个都建立在列表之上。我们使用"list"函数来创建一个列表,但后面你就会发现创建列表的方式不只一种。如果你不想让你列表中的元素被解释执行,记得引用(quote)一下。 => (list "truck" "car" "bicycle" "plane") ;;创建一个列表 ("truck" "car" "bicycle" "plane") ;;与上面方式等价 => '("truck" "car" "bicycle" "plane") ("truck" "car" "bicycle" "plane") ;;查看列表的类型 =>(class '("truck" "car" "bicycle" "plane")) clojure.lang.PersistentList ;; 给创建的列表绑定一个全局变量 => (def vehicles (list "truck" "car" "bicycle" "plane")) #'user/vehicles ;;查看是否是序列 =>(seq? vehicles) true ;;查看是否是列表 =>(list? vehicles) true ;

clojure 新手指南(9):元数据

半城伤御伤魂 提交于 2019-11-28 23:59:42
我们在定义函数的时候提到了如何去定义一个元数据。但之前只是定义它,并没有明说它的用途。让我们再看一下之前定义的select-random函数,我们添加了一个叫做:add的元数据。注意:元数据是以哈希表形式展现的。(键和值可以是任何类型,不过key一般推荐为关键字类型) =>(defn select-random "从一个列表中随机返回一个元素" {:added "1.2"} ;; 元数据 [options] (nth options (rand-int (count options)))) #'user/select-random 我们可以使用下面方式去查看一个函数的元数据信息(一个哈希表): =>(meta #'select-random) {:ns @<Namespace user>@, :name select-random, :file "NO_SOURCE_PATH", :line 1, :arglists ([options]), :added "1.2", :doc "从一个列表中随机返回一个元素"} 我们虽然只定义了一个元数据:add,但是系统却给我们返回了一堆元数据。这些元数据是系统默认给函数添加了,主要是函数的一些基本信息。下面是一些比较重要的信息: :ns 命名空间 :name 函数名 :file 对应的源码文件 :arglists 参数列表

clojure 新手指南(3)复杂表达式求值

守給你的承諾、 提交于 2019-11-28 23:59:30
为了理解复杂的表达式和对它的操作,一个首要的前提就是理解”前缀表达式“。这可能会花费你一点时间来习惯它。不过我相信你会很快的爱上这种规则的。你想想,如果你要对多个值进行同一种运算,你只用写一个运算符在第一个值的最前面,而不是写多个运算符在中间。不信就看下面的例子: 普通: 1 + 2 + 3 + 4 + 5 + 6 + 8 + 9 前缀: + 1 2 3 4 5 6 7 8 9 抛开前缀表示法不说,一个复杂表达式可以看出是一个单独的操作,或者是一组操作。它们既可以接收参数,也能向外输出,在整个表达式计算完成的时候返回计算结果。一句话,复杂的表达式可以做任何你想让它做的事情。让我们看一个非常简单的例子: (+ 1 2) 在对这个式子求值前,我们先去看一看clojure在求值期间会做哪些工作: 首先,clojure会遇到左括号,表明这是一个列表(表达式的形式)的开始。这个列表包含了它要处理的所有东西。clojure永远会把左括号的第一个元素当做是一个操作符( 这也是采用前缀表达式的原因 ),这种方式使得lisp方言语法异常的简单。在我们的例子中,操作符指的就是一个函数。(函数其实可以看出是针对其参数需要做哪些操作的说明)。当clojure遇到一个右括号,表明这个列表的结束。这种解析是递归的,因为列表中的元素依然可能是列表。这种表达方式还有另一个名字:S表达式。(lisp 的含义就是

How to implement a Lisp macro system?

a 夏天 提交于 2019-11-28 22:07:28
问题 I've implemented my own Lisp on top of node.js, I can run s-expressions like this: (assert (= 3 (+ 1 2))) (def even? (fn [n] (= 0 (bit-and n 1)))) (assert (even? 4)) (assert (= false (even? 5))) Now I would like to add macros - the defmacro function - but this is where I'm stuck. I'm wondering how macro systems are implemented in other Lisps but I couldn't find many pointers (apart from this and this). I've looked at the Clojure macro system - the Lisp I'm most familiar with - but that seemed