lisp

Why is consing in Lisp slow?

只谈情不闲聊 提交于 2019-12-03 10:50:18
问题 I read in the book 'On Lisp' that one should avoid excessive use of cons in the body of expanded macros. Why is cons considered to be an inefficient operation? Does Lisp not do structure sharing with the cons cells? 回答1: You need to understand the jargon first. CONS is a primitive operation to create a fresh cons cell. Consing means allocation of memory on the heap in general, not only cons cells: Consing of numbers, Consing of arrays, Consing of CLOS objects, ... The definition from the

common lisp: how can a macro define other methods/macros with programmatically generated names?

别说谁变了你拦得住时间么 提交于 2019-12-03 10:48:31
I realized that a certain section of my code consists of groups of methods that look similar (like I have multiple trios: a helper function that gets called by two other functions meant for the programmer). I'm trying to write a macro that will define these three functions for me so that all I need to do is call the macro. But my attempt results in defuns and function calls that have quoted strings instead of the generated names as new symbols. What am I doing wrong? Example (incorrect code) (defmacro def-trio (base-name) (let ((helper-name (format nil "helper-~a" base-name)) (method-1 (format

Editing programs “while they are running”? How?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 10:29:22
This question is a corollary to: Editing programs “while they are running”? Why? I'm only recently being exposed to the world of Clojure and am fascinated by a few examples I've seen of "live coding". The question linked above discusses the "why." My question is: How is this live coding technique possible? Is it a characteristic of the clojure language which makes it possible? Or is it just a pattern that they applied which could be applied to any language? I've got a background in python and java. Would it be possible to "live code" in either of these languages like it is possible in clojure?

What is the best SQL library for use in Common Lisp? [closed]

可紊 提交于 2019-12-03 10:20:52
Ideally something that will work with Oracle, MS SQL Server, MySQL and Posgress. if you mean common lisp by lisp, then there's cl-rdbms . it is heavily tested on postgres (uses postmodern as the backend lib), it has a toy sqlite backend and it also has an OCI based oracle backend. it supports abstracting away the different sql dialects, has an sql quasi-quote syntax extension installable on e.g. the [] characters. i'm not sure if it's the best, and i'm biased anyway... :) but we ended up rolling our own lib after using clsql for a while, which is i think the most widely used sql lib for cl.

Lisp importing/loading file

人盡茶涼 提交于 2019-12-03 09:58:32
Is there a way in Lisp to include code from other Lisp files? For example, in C++ I can do this: #include <iostream> #include <string> #include "myfile.h" etc... And in Python, import antigravity import my_module etc... Is there a Lisp equivalent? In addition to Rainer's answer: If you want to load ASDF -systems, use: (asdf:load-system 'my-system) Some Lisp implementations (CCL for example) also allow using require for loading ASDF systems, but that functionality is implementation dependent. If you are using Slime, and want to load a system interactively, you can do so by typing ,l my-system

Haskell “Apply”? [duplicate]

大城市里の小女人 提交于 2019-12-03 09:52:57
Possible Duplicate: Why is such a function definition not allowed in haskell? I'm a newcomer to the world of Haskell, migrating over from Lisp. I'm trying to adjust to Haskell's fundamentally different worldview, and one of the many things that I find new and exciting is the type system. Being a Lisper, I thought I would try to implement in Haskell a function which is very important in the Lisp world: apply . For those who don't know, apply takes a function and a list of arguments, and invokes the function on those arguments. In Scheme, (apply + '(1 2 3)) is the same as invoking (+ 1 2 3) ,

Please advise on Ruby vs Python, for someone who likes LISP a lot

倾然丶 夕夏残阳落幕 提交于 2019-12-03 09:47:12
I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature. Which one is closer to LISP: Python or Ruby? I can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression? PS - This might seem like a

Cannot create apply function with static language?

左心房为你撑大大i 提交于 2019-12-03 09:27:57
问题 I have read that with a statically typed language like Scala or Haskell there is no way to create or provide a Lisp apply function: (apply #'+ (list 1 2 3)) => 6 or maybe (apply #'list '(list :foo 1 2 "bar")) => (:FOO 1 2 "bar") (apply #'nth (list 1 '(1 2 3))) => 2 Is this a truth? 回答1: A full APPLY is difficult in a static language. In Lisp APPLY applies a function to a list of arguments. Both the function and the list of arguments are arguments to APPLY. APPLY can use any function. That

What is lisp used for today and where do you think it's going? [closed]

陌路散爱 提交于 2019-12-03 09:25:32
Never been a lisp user, so don't take me as too dense while reading this. However; What is lisp used for today? I know there are several variants of the language in existence, at least one which will keep it alive commercially for a while longer (AutoLisp, VisualLisp - pretty big support from Autodesk)... But I don't meet everyday people using it. So if you could shed some light on the matter: What is its primary target market nowadays? And what do you believe its future will be?.. Will it become just another support language in few apps, or is it going somewhere? Also, apart from "an editor

Check if item is in a list (Lisp)

馋奶兔 提交于 2019-12-03 09:24:33
What's a simple way to check if an item is in a list? Something like (in item list) might return true if item=1 and list=(5 9 1 2) and false if item=7 Common Lisp FIND is not a good idea: > (find nil '(nil nil)) NIL Above would mean that NIL is not in the list (NIL NIL) - which is wrong. The purpose of FIND is not to check for membership, but to find an element, which satisfies a test (in the above example the test function is the usual default EQL ). FIND returns such an element. Use MEMBER : > (member nil '(nil nil)) (NIL NIL) ; everything non-NIL is true or POSITION : > (numberp (position