quote

'(quote quote) in scheme

孤人 提交于 2019-12-20 02:12:58
问题 I'm trying to learn scheme by myself. Could anyone tell me why '(quote quote) will output 'quote , and '(quote 'quote) will output ''quote ? Thank you very much! 回答1: This expression: '(quote quote) ... after expanding '<something> to (quote <something>) is equivalent to (quote (quote quote)) , notice that the symbol quote is being quoted two times, and this expression is evaluated and printed as ''quote . On the other hand, this expression: '(quote 'quote) ... is equivalent to (quote (quote

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

Triple-double quote v.s. Double quote

我的梦境 提交于 2019-12-18 12:08:43
问题 What is the preferred way to write Python doc string? """ or " In the book Dive Into Python, the author provides the following example: def buildConnectionString(params): """Build a connection string from a dictionary of parameters. Returns string.""" In another chapter, the author provides another example: def stripnulls(data): "strip whitespace and nulls" return data.replace("\00", "").strip() Both syntax work. The only difference to me is that """ allows us to write multi-line doc. Is

In Lisp (Clojure, Emacs Lisp), what is the difference between list and quote?

烈酒焚心 提交于 2019-12-18 12:07:32
问题 From reading introductory material on Lisp, I now consider the following to be identical: (list 1 2 3) '(1 2 3) However, judging from problems I face when using the quoted form in both Clojure and Emacs Lisp, they are not the same. Can you tell me what the difference is? 回答1: The primary difference is that quote prevents evaluation of the elements, whereas list does not: user=> '(1 2 (+ 1 2)) (1 2 (+ 1 2)) user=> (list 1 2 (+ 1 2)) (1 2 3) For this reason (among others), it is idiomatic

SuperCSV quote every exported cell

纵然是瞬间 提交于 2019-12-14 01:24:02
问题 I'm using superCSV for exporting bean data to CSV. I'd like every cell double quoted, not just the ones with special characters. Now, using CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE, even the cells with special characters won't get quoted. (With EXCEL_PREFERENCE setting the addresses that contain '.' get quoted.) My goal is to export addresses, phone numbers, everything in a way that MS Office (Hungarian) can use and i.e. won't convert phone numbers like +36000000000 to 36000000000. 回答1:

awk ignore delimiter inside single quote within a parenthesis

大兔子大兔子 提交于 2019-12-13 03:04:05
问题 I have a set of data inside the csv as below: Given Data: (12,'hello','this girl,is lovely(adorable \r\n actually)',goodbye), (13,'hello','this fruit,is super tasty (sweet actually)',goodbye) I want to print the given data into 2 rows starting from ( till ) and ignore delimiter , and () inside the ' ' field. How can I do this using awk or sed in linux? Expected result as below: Expected Result: row 1 = 12,'hello','this girl,is lovely(adorable actually)',goodbye row 2 = 13,'hello','this fruit

Lisp difference between (cons 'a (cons 'b 'c)) and (cons 'a '(b.c))

谁都会走 提交于 2019-12-12 13:11:00
问题 What's the difference between: (cons 'a (cons 'b 'c)) ;; (A B . C) and (cons 'a '(b.c)) ;; (A B.C) I need to create the following list ((a.b).c) using cons so i'm trying to understand what that "." represents. L.E. : I have the following (cons (cons 'a 'b) 'c) but it produces ((A . B) . C) and not ((A.B).C) (Note the extra spaces) 回答1: Spaces are used to separate list tokens. A.B is a single token. (A.B) is a list with a single element. (A . B) is a cons cell with A as car and B as cdr. A

bash_aliases and awk escaping of quotes

别等时光非礼了梦想. 提交于 2019-12-12 08:46:52
问题 I'm trying to create an alias for a command to see the memory use, ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}' but, the naive, #.bash_aliases alias totalmem='ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}'' gives errors: -bash: alias: END: not found -bash: alias: {print: not found -bash: alias: sum/1024}: not found I've tried with double quotes, totalmem ="ps ... |awk '{sum+=$1} END {print sum/1024}'" , or totalmem ='ps

Trying to echo JS function in PHP

寵の児 提交于 2019-12-12 02:37:59
问题 I'm trying to echo a js function in HTML string inside PHP echo. And I can't figure it out : $MY_JS_FUNCTION = '<script type="text/javascript">item + getLastField2()</script>'; if($row2->type == 'text') { echo "<li id='item-".$row2->rank."' class='list_item'>"; echo "<textarea rows='2' id='".$row2->single_id."' cols='90' name='field[".$MY_JS_FUNCTION."]' data-kind='text' >".$row2->content."</textarea>"; echo "</li>"; echo '<br />'; } Any ideas to get this work? I think I have so much quotes