lisp

Why are fixnums in Emacs only 29 bits?

谁说胖子不能爱 提交于 2019-11-29 13:57:17
And why don't they change it? Edit: The reason ask is because I'm new to emacs and I would like to use Emacs as a "programmer calculator". So, I can manipulate 32-bit & 64-bit integers and have them behave as they would on the native machine. Emacs-Lisp is a dynamically-typed language. This means that you need type tags at runtime. If you wanted to work with numbers, you would therefore normally have to pack them into some kind of tagged container that you can point to (i.e. “box” them), as there is no way of distinguishing a pointer from a machine integer at runtime without some kind of

How is set! defined in scheme?

老子叫甜甜 提交于 2019-11-29 12:34:46
How would you implement your own set! function in Scheme? A set! function is a destructive procedure that changes a value that is defined taking into account the previous value. As noted in the comments, set! is a primitive in Scheme that must be provided by the implementation. Similarly, you can't implement the assignment operator, = , in most programming languages. In Common Lisp, setf can be extended (using setf -expanders) to allow (setf form value) to work on new kinds of forms. Because Scheme's set! only modifies variable bindings (like Common Lisp's setq ), it is still worth asking how

How do I globally change a variable value within function in lisp

怎甘沉沦 提交于 2019-11-29 12:13:45
I would like to know if there is any way to mimic C behaviour with pointers in LISP. In C if you change a value of a variable, that pointer is pointing to, it has a global effect (i.e. the value will be changed outside the function too). So if I had (defun mutate ( a ) (some-magic-function a 5) ) a would turn to 5 after calling mutate, no matter what it was before. I know it is possible (much of as a side effect) with elements with lists In common-lisp, how do I modify part of a list parameter from within a function without changing the original list? but I would like to know how to do it for

How do I apply “or” to a list in elisp

若如初见. 提交于 2019-11-29 11:42:29
问题 In elisp I can evaluate or as a function just like +. (or nil 0 nil) ==> 0 (+ 1 0 1) ==> 2 I can use apply to apply + to a list (apply '+ '(1 0 1)) ==> 2 So, I would think or would work the same way, but it doesn't. (apply 'or '(nil 0 nil)) ==> error: (invalid-function or) I imagine this comes from some internal magic used to implement the short-circuit evaluation. How can I use apply to execute the or operation over a list? P.S. my desired application is to find out whether any elements on

Installation of cider-nrepl

血红的双手。 提交于 2019-11-29 11:09:10
问题 I've installed CIDER 0.7.0 and now when I start it inside of Emacs (via M-x cider-jack-in RET ), I get the following warning: WARNING: CIDER's version (0.7.0) does not match cider-nrepl's version (not installed) I've downloaded cider-nrepl and found out that it consists of closure code, not emacs lisp code. Since I've started exploring Clojure world just today, and there is no installation instructions on the project page, could you tell me how can I install cider-nrepl? 回答1: You need to put

Writing a formal language parser with Lisp

醉酒当歌 提交于 2019-11-29 09:42:28
问题 My company is designing a new domain specific scripting language; I have to implement a parser that translates our brand new programming language into a common scripting language so as to be able to enact it. The usual way I do this is by means of Bison and Flex tools that generate the C/C++ code of the translator. I found other tools, for most of the mainstream programming languages, but none for Lisp . Hasn't Lisp ever been used for that? What is the usual way to write a parser with Lisp ?

If you already know LISP, why would you also want to learn F#?

♀尐吖头ヾ 提交于 2019-11-29 09:34:25
问题 What is the added value for learning F# when you are already familiar with LISP? 回答1: Static typing (with type inference) Algebraic data types Pattern matching Extensible pattern matching with active patterns. Currying (with a nice syntax) Monadic programming, called 'workflows', provides a nice way to do asynchronous programming. A lot of these are relatively recent developments in the programming language world. This is something you'll see in F# that you won't in Lisp, especially Common

In Common Lisp, why do multi-expression bodies of (if) statements require (progn)?

筅森魡賤 提交于 2019-11-29 09:18:24
Is this just a bit of historical cruft left over from the 1950s or is there some reason syntactically why multi-expression bodies of (if) forms require (progn)? Why can't you wrap the multiple expressions in a set of parentheses like with (let): (if some-cond ((exp1) (exp2) (exp3)) ; multi exp "then" (exp4)) ; single exp "else" It appears it would be trivial to write a macro to test each body to see first if it is a list and then if it is, if its first element is also a list (and thus not a function invocation) and then to wrap its subcomponents inside a (progn) accordingly. In Common Lisp,

In Lisp, how do I fix “Warning: Assumed Special?”

跟風遠走 提交于 2019-11-29 08:16:10
In this file I get 9 warnings of "assumed special". They are ;;;*** Warning in CHECK-ROW: CHECKARRAY assumed special in SETQ ;;;*** Warning in CHECK-ROW: RESULT assumed special in SETQ ;;;*** Warning in CHECK-ROW: CHECKARRAY assumed special ;;;*** Warning in CHECK-ROW: CHECKARRAY assumed special ;;;*** Warning in CHECK-ROW: CHECKARRAY assumed special ;;;*** Warning in CHECK-ROW: CHECKARRAY assumed special ;;;*** Warning in CHECK-ROW: CHECKARRAY assumed special ;;;*** Warning in CHECK-ROW: RESULT assumed special in SETQ ;;;*** Warning in CHECK-ROW: RESULT assumed special The whole file is just

How to write a scheme function that takes two lists and returns four lists

时光怂恿深爱的人放手 提交于 2019-11-29 08:15:33
I have 2 lists of elements '(a b c) '(d b f) and want to find differences, union, and intersection in one result. Is that possible? How? I wrote a member function that checks if there is a car of the first list in the second list, but I can't throw a member to the new list. (define (checkResult lis1 lis2) (cond........... )) (checkresult '( a b c) '(d b f)) My result should be (( a c) (d f) (a b c d f) (b)) . Like others have said, all you need to do is create separate functions to compute the intersection, union, and subtraction of the two sets, and call them from checkresult: (define