This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test | |
constructor: -> | |
Test.count = 2 | |
@count: 0 | |
@show: -> | |
console.log "Count = #{@count}" | |
console.log ('Not printed' for i in [1..@count]).join(" ") | |
new Test | |
Test.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn =? | |
[a b] | |
(= a b)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn future=? | |
[a f] | |
(let [begin (System/currentTimeMillis) | |
v (= a @f)] | |
(println "Waited" (- (System/currentTimeMillis) begin) "ms") | |
v)) | |
(let [b (future (Thread/sleep 500) 10)] | |
(future=? 10 b)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn channel=? | |
[a c] | |
(let [begin (System/currentTimeMillis) | |
v (= a (<!! c))] | |
(println "Waited" (- (System/currentTimeMillis) begin) "ms") | |
v)) | |
(let [b (thread (<!! (timeout 500)) 10)] | |
(channel=? 10 b)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn =? | |
[a b] | |
(= a b)) | |
(def partial=? (partial =? 10)) | |
;... do some stuff | |
(partial=? 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn =? | |
[a b] | |
(= a b)) | |
(defn channel=? | |
[a c] | |
(thread (=? a (<!! c)))) | |
(def partial=? (partial =? 10)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn mutate-chan | |
[c] | |
(<!! c)) | |
(let [c (chan)] | |
(thread (>!! c 1)) | |
(mutate-chan c) | |
(<!! c)) ; the 1 is now gone! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;So let’s work out the first couple of simple cases: | |
(take 1 head-fibo) | |
(take 1 (lazy-cat [0N 1N] (map + head-fibo (rest head-fibo)))) | |
(take 1 (concat (lazy-seq [0N 1N]) | |
(lazy-seq (map + head-fibo (rest head-fibo))))) | |
;;since we’re taking 1, the 0N of the first lazy-seq suffices and | |
;;we don’t need to further evaluate | |
;; => (0N) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(take 1 head-fibo) | |
(take 1 (lazy-cat [0N 1N] (map + head-fibo (rest head-fibo)))) | |
(take 1 (concat (lazy-seq [0N 1N]) | |
(lazy-seq (map + head-fibo (rest head-fibo))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cljs-line-reader.core | |
(:refer-clojure :exclude [flush]) | |
(:require clojure.string | |
[cljs.core.async :refer [>!]]) | |
(:require-macros [cljs.core.async.macros :refer [go]])) | |
(def fs (js/require "fs")) | |
(def stream (js/require "stream")) | |
(def ^:const eol (.-EOL (js/require "os"))) ;;eg "\n" or "\r\n" |
OlderNewer