英和訓練

著作権は原文に属します

Learn Clojure - Hashed Collection ハッシュなコレクション

As described in the previous section, there are four key Clojure collection types: vectors, lists, sets, and maps. 前回の節で述べたように、Clojureには4つの重要なコレクション型がある。ベクタ、リスト、セット、マップである。Of those four collection types, sets and maps are hashed collections, designed for efficient lookup of elements. 4つの中でセットとマップとは、効率的な検索のために設計された、ハッシュを用いたコレクションである。

続きを読む

Learn Clojure - Sequential Collections シーケンシャルなコレクション

Clojure collections "collect" values into compound values. Clojureのコレクションとは、任意個の値を集めて(コレクトして)、1つの複合的な値としたものだ。There are four key Clojure collection types: vectors, lists, sets, and maps. Clojureにおいて重要なコレクション型は、ベクタ、リスト、セット、マップの4つである。Of those four collection types, vectors, and lists are ordered. これら4つのコレクション型のうち、ベクタとリストは順序のあるコレクションである。

続きを読む

Learn Clojure - Functions 関数

Creating Functions 関数を作る

Clojure is a functional language. Clojure関数型言語の一つだ。Functions are first-class and can be passed-to or returned-from other functions. 関数は第一級であり、他の関数に渡されたり、関数から返されたりする。Most Clojure code consists primarily of pure functions (no side effects), so invoking with the same inputs yields the same output. ほとんどのClojureコードは主に(副作用のない)純粋な関数らによって構成されているから、同じ入力で呼び出せば同じ出力を生じる。

続きを読む

Function reduce1 in clojure? Clojureの関数reduce1

Is reduce1 not in the clojure.core? reduce1clojure.coreの中にないのですか? I am using Emacs with CIDER and i don't have reduce1, (doc reduce1) returns nil. 私はEmacsでCIDERを使っているのですが、reduce1がありません。(doc reduce1)とするとnilが返ってきます。 - ateymuri

You only tagged this as clojure but how should we know what reduce1 does? この質問をclojureとだけタグづけしたようだけど、それでは、reduce1が何をするものなのか分からないよ。Can you describe this function that you've missing? あなたが見当たらないというその関数について説明してもらえる? - ClojureMostly

I was checking the source of merge and reduce1 is used there, so i checked for it but didn't found it in my version 1.7. mergeのソースを見ていたらreduce1が使われていたんだ。だからそれを調べようとしたけど、私が使っているバージョン1.7では、それが見つからなかった。It seems to be added to the clojure.core since 1.8. この関数はバージョン1.8からclojure.coreに追加されたみたいだ。 - ateymuri

reduce1 is an implementation detail of Clojure core. reduce1Clojureのコアの実装の詳細だ。Don't use it. これを使わないでください。It might disappear and it may not even exist in ClojureScript or Clojure for CLR. これは将来なくなるかもしれないし、ClojureScriptあるいはCLRClojureでは存在さえしないかもしれない。 - Thumbnail

by Daniel Compton

reduce1 is a private reduce function used in Clojure's bootstrapping of clojure.core. reduce1Clojureclojure.coreを起動する際に使っているプライベートなreduce関数だ。It is needed because some of the things that reduce need to work haven't been loaded yet. これは、reduceが動作するのに必要なものがまだロードされていない時点で必要とされ使われている。You shouldn't use reduce1 in your own code, always prefer reduce. あなた自身のコードでreduce1を使うべきではありません。必要なら常にreduceを使ってください。

What does it mean that a function is a private function? ある関数がプライベート関数であるとは、どういう意味ですか? - ateymuri

That is cannot be used outside of it's own namespace それ自身の名前空間の外側から使うことはできない - NielsK

by dsm

The function is defined in line 895 of clojure.core, but marked private, and later redefined as plain reduce. その関数はclojure.coreの895行目で定義されているが、プライベートだとマークされている。そして後に、単なるreduceとして再定義されているよ。

原文: https://stackoverflow.com/questions/33665736/function-reduce1-in-clojure

(WIP) Clojure from the ground up: macros マクロ

https://aphyr.com/posts/305-clojure-from-the-ground-up-macros

In Chapter 1, I asserted that the grammer of Lisp is uniform: every expression is a list, beginning with a verb, and followed by some arguments. 第1章で強調したとおり、Lispの文法の形は一通りである。全ての式はリストであり、そのリストは動詞で始まって、いくつかの引数が続く。Evaluation proceeds from left to right, and every element of the list must be evaluated before evaluating the list itself. 評価は左から右へ進む。リストの全ての要素は、リスト自体が評価されるよりも前に評価されねばならない。Yet we just saw, at the end of Sequences, an expression which seemed to violate these rules. しかしつい先ほど、シーケンスについての章の最後で、その規則に則っていない式を見た。

続きを読む