English 中文(简体)
在Clojure,如何混淆或混淆收集的内容,而不是收集本身?
原标题:In Clojure, how to cons or conj the elements of a collection but not the collection itself?
  • 时间:2011-10-04 18:04:09
  •  标签:
  • clojure
  • lisp

目前的情况类似:

(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)




相关问题
Lisp code called from Java

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 ...

Emacs, Zen-Coding mode, and Putty

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 ...

In Which Cases Is Better To Use Clojure? [closed]

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

lambda-gtk negative pointer

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 ...

Is there a common lisp package naming convention?

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 ...

SOAP request from within an AutoLISP/AutoCAD macro

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 ...

热门标签