lisp

How to handle accents in Common Lisp (SBCL)?

给你一囗甜甜゛ 提交于 2019-12-20 02:28:12
问题 That's probably very basic, but I didn't know where else to ask. I'm trying to process some text information in an SLIME REPL from a file that are written in Portuguese, hence uses lots of accents characters - such as é, á, ô, etc.. When I'm handling texts in English I use the following function: (defun txt2list (name) (with-open-file (in name) (let ((res)) (do ((line (read-line in nil nil) (read-line in nil nil))) ((null line) (reverse res)) (push line res)) res))) that cannot read accented

how to test whether one list is a member of another

孤街浪徒 提交于 2019-12-19 19:48:07
问题 Lets say I have two lists, ((1 2 3)) and (((1 2 3)) ((4 5))) . I want to be able to tell if the first list is a member of the second list. I have tried to use subsetp , but it does not return true for this query. How can I accomplish this? 回答1: As Rainer Joswig mentioned in the comments, you're not checking for subsets, but for members, which you can do using the aptly named member function. Member returns a generalized boolean, i.e., nil for false, and something, not necessarily t , non- nil

Convert string to code in Scheme

会有一股神秘感。 提交于 2019-12-19 17:44:14
问题 How do I convert a string into the corresponding code in PLT Scheme (which does not contain the string->input-port method)? For example, I want to convert this string: "(1 (0) 1 (0) 0)" into this list: '(1 (0) 1 (0) 0) Is it possible to do this without opening a file? 回答1: Scheme has procedure read for reading s-expressions from input port and you can convert a string to input stream with string->input-port . So, you can read a Scheme object from a string with (read (string->input-port "(1 (0

Why in LISP , there is no limitation for number?

允我心安 提交于 2019-12-19 16:55:10
问题 I can even calculate ( expt 32768 32768 ) and I got: 476170470581645852036305042887575891541065808607552399123930385521914333389668342420684974786564569494856176035326322058077805659331026192708460314150258592864177116725943603718461857357598351152301645904403697613233287231227125684710820209725157101726931323469678542580656697935045997268352998638215525166389437335543602135433229604645318478604952148193555853611059596230656 回答1: Lisp automatically switches math to use a bignum package when

How to cast a character to int in Clojure?

僤鯓⒐⒋嵵緔 提交于 2019-12-19 15:26:12
问题 How to cast a character to int in Clojure? I am trying to write a rot 13 in clojure, so I need to have something to cast my char to int. I found something called (int), so I put: (int a) Get: CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:13:1) Then I put: (int 'a) Get: ClassCastException clojure.lang.Symbol cannot be cast to `java.lang.Character clojure.lang.RT.intCast (RT.java:1087) Then: (rot13 ''a') Get:

How to cast a character to int in Clojure?

微笑、不失礼 提交于 2019-12-19 15:26:07
问题 How to cast a character to int in Clojure? I am trying to write a rot 13 in clojure, so I need to have something to cast my char to int. I found something called (int), so I put: (int a) Get: CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:13:1) Then I put: (int 'a) Get: ClassCastException clojure.lang.Symbol cannot be cast to `java.lang.Character clojure.lang.RT.intCast (RT.java:1087) Then: (rot13 ''a') Get:

slimv segfaulting on OS X Lion

廉价感情. 提交于 2019-12-19 11:28:36
问题 I have been trying to get slimv (http://www.vim.org/scripts/script.php?script_id=2531) working for a while now, but I am really not sure what else I can do. I am running vim 7.3 compiled with python support, using clisp (sbcl is showing the same issue though) on os x lion. I pulled the latest version of slimv off of vim.org. When I load a lisp file, echo g:slimv_loaded returns 1, but I do not get a second window with the repl. When I hit any of the keybindings, a new terminal window opens,

Cannot use function call as first argument in s-exp [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-19 10:52:40
问题 This question already has answers here : Do any lisps have a s-expression as their head, e.g. ((f 2) 3 4)? If not, why? (3 answers) Why do we need funcall in Lisp? (3 answers) Closed 5 years ago . I'm trying to use a function to return a function in common lisp. However, I've run into a strange situation I'd like explained. This is what I want to do: (defun makefun(x) ;1 (lambda (z) (+ x z))) ((makefun 1) 2) ;2 This results in an illegal function call. However, the following are valid: (

Why does (list 'quote 'x) evaluate to 'x and not ('x) or (quote 'x)?

只谈情不闲聊 提交于 2019-12-19 07:47:33
问题 I'm trying to learn LISP and was going through a code example where something similar to the following code is used: (list 'quote 5) This evaluates to '5 in the REPL. I expected it to evaluate to ('5) or (quote 5) I'm trying this out in the CLISP REPL. Any help would be appreciated. 回答1: The read-evaluate-print loop first reads, then evaluates 'quote is read as "the symbol whose name is QUOTE" 5 is read as "the number 5" So (list 'quote 5) is evaluated as "make a list whose first element is

Why does (list 'quote 'x) evaluate to 'x and not ('x) or (quote 'x)?

我与影子孤独终老i 提交于 2019-12-19 07:47:06
问题 I'm trying to learn LISP and was going through a code example where something similar to the following code is used: (list 'quote 5) This evaluates to '5 in the REPL. I expected it to evaluate to ('5) or (quote 5) I'm trying this out in the CLISP REPL. Any help would be appreciated. 回答1: The read-evaluate-print loop first reads, then evaluates 'quote is read as "the symbol whose name is QUOTE" 5 is read as "the number 5" So (list 'quote 5) is evaluated as "make a list whose first element is