Abbreviation of definition. [(semantics, lexicography) A statement of the meaning of a word, word group, sign, or symbol; especially, a dictionary definition.]
defn
Definition, parts of speech, synonyms, and sentence examples for defn.
Editorial note
For example, in Clojure: (defn foo [list] (defn n-to-nth [n] (Math/pow n n)) (map n-to-nth list)) Would intern the symbol 'n-to-nth in the current namespace.
Quick take
Abbreviation of definition. [(semantics, lexicography) A statement of the meaning of a word, word group, sign, or symbol; especially, a dictionary definition.]
Meaning at a glance
The clearest senses and uses of defn gathered in one view.
Definitions
Core meanings and parts of speech for defn.
noun
Abbreviation of definition. [(semantics, lexicography) A statement of the meaning of a word, word group, sign, or symbol; especially, a dictionary definition.]
Example sentences
For example, in Clojure: (defn foo [list] (defn n-to-nth [n] (Math/pow n n)) (map n-to-nth list)) Would intern the symbol 'n-to-nth in the current namespace.
The `if-match` macro you describe could be written as a function, albeit with less pleasing syntax: (defn if-match [pat expr then else] (if-let [match (if (fn?
(defn next-happy [n] (reduce + (map #(* % %) (int-to-digits n)))) (defn happy?
This makes implementing defn (and by extension a user macro like it) much easier.
I'm used to Lisps, where def/defun/define/defn imply internment.
- Gratuitous use of [] in some forms; mainly defn and let.
But defn, I didn't find them surprising.
(defn int-to-digits [n] (map #(Character/getNumericValue %) (str n))) (I had to Google Character/getNumericValue - doubt anyone expects you to memorize that).
I would feel uncomfortable to use the quotest to define something, like: fact 'defn arity func' I think it would cause problems to have a good syntax hihlighting in the text editor.
(defn f [a:- Dyn]:- Dyn a) Running (inc (f 1)) would wrap 1 in Dyn, then a Dyn exits as a return value, so no further wrapping is needed.
While I agree that C# has a non-trivial class boilerplate and non-zero function boilerplate, the Clojure you quoted doesn't even show any function boilerplate (defn foo [args] body) I compared a C# 3 expression to a Clojure expression.
(defn [items] [:ul.items (for [item items] [:li.item (:display-name item)]])]) Then whenever you change the state of 'items', the component will automatically re-render and inject the new DOM as necessary using React's diffing algorithm for high performance.
Quote examples
It's true that the PD also "shows why two purely 'rational' individuals might not cooperate" but that is not part of the defn of PD.
(defn hello [] (println "hello world")) (hello);; in Clojure (defun hello () (format t "hello world")) (hello);; in Common Lisp.
The same code in Clojure: (let [hello (fn [] (println "Hello World"))] (hello)) Or assuming hello is a global in your dart example: (defn hello [] (println "Hello World")) (hello) Nothing too complicated about that.
Check out clojure core's min function: (defn ^number min "Returns the least of the nums." ([x] x) ([x y] (cljs.core/min x y)) ([x y & more] (reduce min (cljs.core/min x y) more))) So there are occasions for this related to efficiency.
Frequently asked questions
Short answers drawn from the clearest meanings and examples for this word.
How do you use defn in a sentence?
For example, in Clojure: (defn foo [list] (defn n-to-nth [n] (Math/pow n n)) (map n-to-nth list)) Would intern the symbol 'n-to-nth in the current namespace.
What does defn mean?
Abbreviation of definition. [(semantics, lexicography) A statement of the meaning of a word, word group, sign, or symbol; especially, a dictionary definition.]
What part of speech is defn?
defn is commonly used as noun.