天道酬勤,学无止境

quote

调用破坏性 Common LISP 函数的奇怪行为接收用引号创建的列表作为参数(Strange behavior invoking destructive Common LISP function receiving as argument a list created with quote)

问题 在调用一个破坏性定义时,我遇到了一个奇怪的行为,该定义接收一个局部变量作为参数,该变量的类型是一个用引号创建的列表。 破坏功能: (defun insert-at-pos (pos list elem) (if (= pos 0) (cons elem list) (let ((aux-list (nthcdr (1- pos) list))) (setf (rest aux-list) (cons elem (rest aux-list))) list))) 错误:局部变量是使用特殊运算符引号创建的列表。 (defun test () (let ((l '(1 2 3))) (print l) (insert-at-pos 2 l 4) (print l))) > (test) (1 2 3) (1 2 4 3) (1 2 4 3) > (test) (1 2 4 3) (1 2 4 4 3) (1 2 4 4 3) > (test) (1 2 4 4 3) (1 2 4 4 4 3) (1 2 4 4 4 3) 正确:局部变量是用函数列表创建的列表。 (defun test2 () (let ((l (list 1 2 3))) (print l) (insert-at-pos 2 l 4) (print l))) 或者 (defun test2 () (let ((l

2021-09-24 04:42:53    分类:技术分享    list   lisp   common-lisp   quote

Strange behavior invoking destructive Common LISP function receiving as argument a list created with quote

I've been getting a strange behavior when invoking a destructive definition receiving as argument a local variable whose type is a list created with a quote. Destructive function: (defun insert-at-pos (pos list elem) (if (= pos 0) (cons elem list) (let ((aux-list (nthcdr (1- pos) list))) (setf (rest aux-list) (cons elem (rest aux-list))) list))) WRONG: Local variable is a list created with the special operator quote. (defun test () (let ((l '(1 2 3))) (print l) (insert-at-pos 2 l 4) (print l))) > (test) (1 2 3) (1 2 4 3) (1 2 4 3) > (test) (1 2 4 3) (1 2 4 4 3) (1 2 4 4 3) > (test) (1 2 4 4 3)

2021-09-23 21:15:47    分类:问答    list   lisp   common-lisp   quote

在传递给 sum() 之前强制评估索引表达式(Force evaluate index expression before passing to sum())

问题 我想编写一个(以某种方式)增强的 sum 函数,它一次需要多个索引,但我无法理解如何让它工作。 这是我目前拥有的: (%i1) nsum(indexes, expr) := if indexes = [] then expr else nsum(rest(indexes), sum(expr, first(indexes),1, N)) $ (%i2) nsum([i,j], i+j), nouns; sum: index must be a symbol; found intosym(first(indexes)) #0: nsum(indexes=[k,j],expr=k+j) 我认为这可以通过在传递给sum函数之前强制 Maxima first(indexes)扩展first(indexes)为符号来解决。 我试过''(...)和ev(..., nouns) ,但没有任何成功。 回答1 经过一些阅读和尝试后,我得出了以下解决方案,该解决方案使用apply函数来预评估sum参数: nsum(indexes, expr) := if indexes = [] then expr else nsum(rest(indexes), apply(sum, ['expr, indexes[1], 1, N])) $ UPD1: 不幸的是,上面的代码有问题

2021-09-23 09:43:33    分类:技术分享    symbolic-math   quote   maxima   computer-algebra-systems

Gmail-API request quota at a user level

Note: This question is about something that I do not understand in the documentation here: https://developers.google.com/gmail/api/v1/reference/quota#concurrent_requests Concurrent Requests The Gmail API enforces a per-user concurrent request limit (in addition to the per-user rate limit). This limit is shared by all Gmail API clients accessing a given user and ensures that no API client is overloading a Gmail user mailbox or their backend server. enforces a per-user concurrent request limit (in addition to the per-user rate limit). I do not find what is the 'per-user concurrent request'

2021-09-06 23:02:31    分类:问答    google-api   gmail-api   quote

Force evaluate index expression before passing to sum()

I want to write an (somehow) enhanced sum function which takes a number of indices at once, but I cannot understand how to get it work. Here is what I currently have: (%i1) nsum(indexes, expr) := if indexes = [] then expr else nsum(rest(indexes), sum(expr, first(indexes),1, N)) $ (%i2) nsum([i,j], i+j), nouns; sum: index must be a symbol; found intosym(first(indexes)) #0: nsum(indexes=[k,j],expr=k+j) I think this could be fixed by forcing Maxima expand first(indexes) into a symbol before passing to sum function. I tried ''(...) and ev(..., nouns), but without any success.

2021-09-03 18:48:01    分类:问答    symbolic-math   quote   maxima   computer-algebra-systems

PHP exec, system or passthru all remove single or double quotes

When ever I try to execute a command to the shell via php's exec/passthru/system functions it seems to remove quotes from the command. $str_file = '1323988284_700.csv'; exec("/usr/bin/lftp -e 'set ftp:passive-mode true; set ftp:ssl-protect-data yes; put /web/files/{$str_file}; bye;' -u user,pass ftp://ftp.site.com/uploaddir/"); Here is the output from checking the process ps faxxx | grep lftp 4486 ? S 0:00 | \_ /usr/bin/lftp -e set ftp:passive-mode true; set ftp:ssl-protect-data yes; put /web/files/1323988284_700.csv; bye; -u user,pass ftp://ftp.site.com/uploaddir/ As you can see it's showing

2021-09-03 07:06:50    分类:问答    php   linux   exec   quote

Is there a way of using PHP PDO::quote method without creating a connection?

I've been using PDO::quote to generate SQL statements. I use the generated SQL to create a memcached key. I'd like to avoid having to create a connection solely for the purpose of escaping SQL values. What is the purpose of needing to establish a connection to use PDO::quote method and can it be avoided?

2021-09-03 06:15:31    分类:问答    php   pdo   quote

" 代替引号 (")(" instead sign of quote ("))

问题 我在 C# 中编写了 asp.net web projet。 问题在于将引号"保存在数据库中并在页面中再次显示。 例如有一个文本框,我输入以下内容: "abcd" 并将其保存在数据库中。 但是,当我再次阅读本文并将其显示在页面中时,我看到: "abcd" 那么这里有什么问题?有人知道解决方案吗? 我使用的字符集是 utf8 和 collat​​tion 是 utf8generalci 回答1 尝试使用 HTML 解码和编码 HttpUtility.HtmlDecode 参考 http://msdn.microsoft.com/en-us/library/aa332854%28v=vs.71%29.aspx 回答2 这实际上是期望的行为 - " 是转义的 html 实体" 。输出文字”是一个安全问题,因为它可以启用跨站点脚本或跨站点请求伪造。 // 抱歉,请注意下面自由落体的正确答案。

2021-09-02 02:42:45    分类:技术分享    c#   asp.net   character-encoding   sign   quote

在 C 中打印 "(双引号)(Printing " (double quote) in C)

问题 我正在编写一个 C 代码,它从一个文件中读取并生成一个中间.c文件。 为此,我使用fprintf()打印到该中间文件中。 我怎样才能打印" ? 回答1 您可以使用转义符\"例如 puts( "\"This is a sentence in quotes\"" ); 或者 printf( "Here is a quote %c", '\"' ); 或者 printf( "Here is a quote %c", '"' ); 回答2 如果您只想打印单个"字符: putchar('"'); "不必在字符常量中转义,因为字符常量由'分隔,而不是" 。 (如果您愿意,您仍然可以转义它: '\"' 。) 如果它是字符串文字中较大输出块的一部分,则需要对其进行转义,这样它就不会被视为文字的结束" : puts("These are \"quotation marks\"\n"); 或者 printf("%s\n", "These are \"quotation marks\"");

2021-09-01 12:55:20    分类:技术分享    c   printf   double-quotes   quote

" instead sign of quote (")

I have writteln asp.net web projet in C#. The problem is in saving sign of quote " in a database and displaying this again in a page. For example there is a textbox and I type following: "abcd" and save this in DB. However, when I read this again and display it in a page I see: "abcd" So what is a problem here?Does someone know the solution? the charset I use is utf8 and colattion is utf8generalci

2021-08-31 08:20:18    分类:问答    c#   asp.net   character-encoding   sign   quote