目前的情况类似:
(cons (1 2) (3))
;=> ((1 2) 3)
我愿实现:
(magic-cons (1 2) (3))
;=> (1 2 3)
我找不到这方面的资源,但我觉得应该建立职能。
或者我不知道用文字来描述这种情况。 不管怎样,请让我知道。 感谢!
Edit: Please don t answer with "flatten" :P ie
(flatten (cons (1 2) (3)))
目前的情况类似:
(cons (1 2) (3))
;=> ((1 2) 3)
我愿实现:
(magic-cons (1 2) (3))
;=> (1 2 3)
我找不到这方面的资源,但我觉得应该建立职能。
或者我不知道用文字来描述这种情况。 不管怎样,请让我知道。 感谢!
Edit: Please don t answer with "flatten" :P ie
(flatten (cons (1 2) (3)))
您必须使用concat
:
clojure.core/concat
([] [x] [x y] [x y & zs])
Returns a lazy seq representing the concatenation of the elements in the supplied colls.
样本使用:
user> (concat (1 2) (3))
(1 2 3)
我确实认为,你正在寻找concat 。 (设想“稳定名单”):
[Concat] 归还了一种 la,即所供应的 coll中元素的分类。
在这种情况下,使用方式是:
(concat (1 2) (3))
注:与(many)其他电离线器-方言不同,克隆法-concat
页: 1 见。 • 如何将 sequence序列封到在衣物中的非la?
幸福 co。
另一种选择是“into”。
第一种论点的类型总是归来的,与总是回到清单的目录不同。
=> (into [2 4] (1 2 3))
[2 4 1 2 3]
(into (2 4) (1 2 3))
(3 2 1 2 4)
Long story: I am doing a project for my functional programing class, and I thought of writing an AI controller in Lisp, for the Mario AI competition. I was looking over frameworks/libraries/ways of ...
I use emacs via Putty and since Putty doesn t send certain key combinations to the remote console I generally need to re-bind them to other key combinations. After installing the amazing Zen-Coding ...
I develop in Lisp and in Scheme, but I was reading about Clojure and then I want to know, in which cases is better to use it than using Lisp or Scheme? Thanks
If I have a list of 0 s, how would I modify, for example, the 16th 0 in the list?
I was trying to write my own put-pixel on (Gdk) pixbuf in Lisp. When I finally realized how I can operate on C pointers in CL, new obstacle came along - (gdk:pixbuf-get-pixels pb) returns me negative ...
I have created some of my own user packages and have run into a name clash. In Java, the naming convention is to use your domain name in the package name: e.g. import com.example.somepackage;. Are ...
We have built a webservice for a client that uses AutoCAD. They have a macro that runs in AutoCAD that builds a SOAP request. But they have not figured out how to actually send() the soap request to ...
In Chapter 9 of the Little Schemer, the Author presents the following two functions (define Q (lambda (str n) (cond ((zero? (remainder (first$ str ) n)) (Q (second$ str ) n)) ...