我有一个里面有文字的 div。如果文本溢出它的 div,它会在末尾用省略号缩短。我想要做的是在椭圆后添加双引号,使其看起来像这样:
“快哥……”
这是我的代码:
<html><body>
<div style="width: 100px;background: #CCCCCC;">
<div style="overflow:hidden; white-space: nowrap; text-overflow: ellipsis;">"The quick brown fox"
</div></div>
</body></html>
Run Code Online (Sandbox Code Playgroud)
是否有一种简单的方法/技术可以做到这一点,或者您是否需要创建自己的自定义省略号?
谢谢大家!
让我看看我的代码
代码1:
(eqv? 'lambda 'quote)
Run Code Online (Sandbox Code Playgroud)
返回 #f
代码2:
(case 'lambda ('quote "equal") (else "not equal"))
Run Code Online (Sandbox Code Playgroud)
返回"not equal"但生成警告;;; <stdin>:17:0: warning: duplicate datum quote in clause ((quote quote) "equal") of case expression (case (quote lambda) ((quote quote) "equal") (else "not equal"))
Code3:奇怪的结果
(case 'quote ('lambda "equal"))
Run Code Online (Sandbox Code Playgroud)
返回"equal",没有警告
我使用了解释代码guile (GNU Guile) 2.0.11.以下是gnucase语法的描述
使用eqv将评估结果与所有基准进行比较?
我正在尝试从proc 宏研讨会实现构建器模式我正在创建一个 proc 宏,它解析一个结构,提取其name,field_names和field_types. 它应该重现结构本身,并创建一个具有相同field_names但具有可选类型的构建器结构。
我的问题是,field_name并且field_type是迭代器,我必须使用两次才能从一个结构中创建两个结构。
这是我的源代码树
.
??? Cargo.lock
??? Cargo.toml
??? builder-derive
? ??? Cargo.toml
? ??? src
? ??? lib.rs
??? src
??? main.rs
Run Code Online (Sandbox Code Playgroud)
./cargo.toml
[package]
name = "proc-macro-question"
version = "0.1.0"
authors = ["ropottnik <ropottnik@example.com>"]
edition = "2018"
[dependencies]
builder-derive = { path = "./builder-derive" }
Run Code Online (Sandbox Code Playgroud)
./main.rs
[package]
name = "proc-macro-question"
version = "0.1.0"
authors = ["ropottnik <ropottnik@example.com>"]
edition = …Run Code Online (Sandbox Code Playgroud) 我是 Lisp 初学者,我正在努力理解为什么下面的代码给我一个错误。
(dolist (elem '(mapcar
mapcon))
(when (fboundp `',elem) (print "hello")))
Run Code Online (Sandbox Code Playgroud)
谢谢。
编辑: 更多的上下文。我在 Elisp 中写了以下内容,但我不知道如何修复它。
(dolist (ui-elem '(menu-bar-mode
tool-bar-mode
tooltip-mode
scroll-bar-mode
horizontal-scroll-bar-mode))
(when (fboundp `',ui-elem) (ui-elem -1)))
Run Code Online (Sandbox Code Playgroud) 我一直在调用一个破坏性的定义时接受一个奇怪的行为,接收一个局部变量作为参数,其类型是一个用引号创建的列表.
破坏性功能:
(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)))
Run Code Online (Sandbox Code Playgroud)
错误:局部变量是使用特殊运算符引号创建的列表.
(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 …Run Code Online (Sandbox Code Playgroud) 使用quote do:记录引用时不会转换为包含记录字段的元组:
iex(1)> quote do: is_bitstring("blah")
{:is_bitstring, [context: Elixir, import: Kernel], ["blah"]}
iex(2)> quote do: Computer.new("Test")
{{:., [], [{:__aliases__, [alias: false], [:Computer]}, :new]}, [], [[name: "Test"]]}
iex(3)> quote do: Computer.new("Test")
{{:., [], [{:__aliases__, [alias: false], [:Computer]}, :new]}, [], [[name: "Test"]]}
iex(4)> c = Computer.new("Test")
Computer[name: "Test", type: nil, processor: nil, hard_drives: []]
iex(5)> c
Computer[name: "Test", type: nil, processor: nil, hard_drives: []]
iex(6)> quote do: c
{:c, [], Elixir}
Run Code Online (Sandbox Code Playgroud)
此外,当我尝试在我的代码中执行此操作时:
defmacro computer([do: code]) do
# macro login here …Run Code Online (Sandbox Code Playgroud) 为什么http://www.lisperati.com/clojure-spels/data.html使用带引号的符号而不是关键字?
(def objects '(whiskey-bottle bucket frog chain))
(def game-map (hash-map
'living-room '((you are in the living room
of a wizards house - there is a wizard
snoring loudly on the couch -)
(west door garden)
(upstairs stairway attic))
'garden '((you are in a beautiful garden -
there is a well in front of you -)
(east door living-room))
'attic '((you are in the attic of the
wizards house - there is a giant
welding torch in the corner …Run Code Online (Sandbox Code Playgroud) 我尝试让用户可以在CustomerName中搜索带引号的客户.
用户在customerNameTextBox中搜索设置为customerNameTB的用户.
如果用户使用引号('),它将被替换为双引号.
如果有三重引号('''),它将被替换为双引号.
这是我的代码:
string customerNameTB = customerNameTextbox.Text;
customerNameTB.Replace("'", "''");
while (customerNameTB.Contains("'''"))
{
customerNameTB.Replace("'''", "''");
}
Run Code Online (Sandbox Code Playgroud)
此代码后的结果是引号仍是单引号.
这条小代码有什么问题.
在答案后编辑
我的代码应如下所示:
string customerNameTB = customerNameTextbox.Text;
customerNameTB = customerNameTB.Replace("'", "''");
while (customerNameTB.Contains("'''"))
{
customerNameTB = customerNameTB.Replace("'''", "''");
}
Run Code Online (Sandbox Code Playgroud) 我是clojure的新手。我想通过以下方式在clojure中使用quote:
首先,我定义一个变量:
(def狗“动物”)
然后是一个函数:
(defn what-is [名称]
('name(str“是” name)))
如果我使用变量dog作为参数调用函数what-is:(what-is dog)
结果应为:
USER >>狗是动物
在这里,我返回了传递给函数what-is的参数的名称,而不是其值:
我得到的是:
是动物
这里没有提到参数狗。
同样,我要寻找的是“字面意义上的”重复传递给函数的参数的名称,如以下模板所示:
(what-is x)=> x是一个...
谢谢。
我不明白为什么
(setq a_sym 'abc)
(print (eq a_sym 'abc))
(print (eq 'x 'x))
(print (eq (first '('x 2 3)) 'x))
Run Code Online (Sandbox Code Playgroud)
版画
T
T
NIL
Run Code Online (Sandbox Code Playgroud)
为什么'x第三个语句中的符号与第二个语句的处理方式不同?并且,脚踏实地,如何比较它们的身份?