- run
ibus-setup
in a terminal - switch to Emoji tab of IBus Preferences window
- click ... button to the right of Emoji chocie input
- select <Control><Shift>e from Keyboard shortcuts
- click Delete
- click OK
- click Close
;; this is a little Clojure code snippet that hopefully helps one understand why | |
;; the order in which components of a composite transducer passed to the `comp` | |
;; fn feels backward when compared to that of regular fn compositions. | |
;; in the following `defn`s, `rf` is a "reducing fn", i.e., any fn that `reduce` | |
;; expects as its first argument (e.g., `+`, `conj`, etc.) | |
;; a transducer | |
(defn g [rf] | |
(fn [r x] ; this fn itself is a reducing fn |
Clojure programs are composed of expressions. Every form not handled specially by a special form or macro is considered by the compiler to be an expression, which is evaluated to yield a value. [1]
An expression is a form which will be (or can be) evaluated in the final program. [2]
For instance, consider the form (fn [x] (inc x))
. It is a list of three elements: the special form fn
, the vector [x]
, and the list (inc x)
. All of those elements are forms, but only the last is an expression, because it is "intended" for evaluation; the first two forms are shuffled around by the macroexpander but never evaluated. The outermost form (fn [x] (inc x))
is itself an expression as well.
This seems to be an interesting distinction, but it does mean it is context-sensitive: [x]
is always a form, and may or may not be an expression depending on context. For instance, as in the example above ((fn [x] (inc x))
), [x]
is a form not an expression because it's handled specially by the special form fn
;
(conj collection item)
adds item
to collection
. To do that, it needs to realize collection
. (I'll explain why below.) So the recursive call happens immediately, rather than being deferred.
(cons item collection)
creates a sequence which begins with item
, followed by everything in collection
. Significantly, it doesn't need to realize collection
. So the recursive call will be deferred (because of using lazy-seq
) until somebody tries to get the tail of the resulting sequence.
The following is how it works internally:
cons
actually returns a clojure.lang.Cons
object, which is what lazy sequences are made of. conj
returns the same type of collection which you pass it (whether that is a list, vector, or whatever else). conj
does this using a polymorphic Java method call on the collection itself. (See line 524 of clojure/src/jvm/clojure/lang/RT.java
.)
What happens w
;; | |
;; www.4clojure.com | |
;; | |
;; #19 last element | |
(comp first reverse) | |
;; (partial reduce (fn [_ x] x)) | |
;; (fn [coll] (reduce (fn [_ x] x) coll)) | |
;; (partial reduce #(identity %2)) |
;; Evaluate the following to get a list of all typefaces and pick an Arabic typeface from it. | |
;; (In my case, it was "PakType Naskh Basic".): | |
(print (font-family-list)) | |
;; Add the following line to ~/.emacs/init.el (or ~/.emacs) | |
;; (Change the name of the typeface at the end to that of the one you picked above.): | |
(when window-system | |
(set-fontset-font "fontset-default" '(#x600 . #x6ff) "PakType Naskh Basic")) |
// <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.js"></script> | |
// <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js"></script> | |
/* | |
<body> | |
<div id="root" /> | |
</body> | |
*/ | |
// redux api |
// <script src="https://cdnjs.cloudflare.com/ajax/libs/expect/1.20.2/expect.min.js"></script> | |
// redux api | |
const combineReducers = reducers => | |
(state = {}, action) => | |
Object.keys (reducers). | |
reduce ((accumulator, key) => Object.assign ({}, accumulator, {[key]: reducers [key] (state [key], action)}), {}) | |
Because all those advantages are also disadvantages.
Stateless programs; No side effects
Real-world programs are all about side effects and mutation. When the user presses a button it's because they want something to happen. When they type in something, they want that state to replace whatever state used to be there. When Jane Smith in accounting gets married and changes her name to Jane Jones, the database backing the business process that prints her paycheque had better be all about handling that sort of mutation. When you fire the machine gun at the alien, most people do not mentally model that as the construction of a new alien with fewer hit points; they model that as a mutation of an existing alien's properties. When the programming language concepts fundamentally work against the domain being modelled, it's hard to justify using that language.
Concurrency; Plays extremely nice with the rising multi-core technology
The problem is just pushed around. With immutable data structures you have ch