Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
(ns n01se.externs-for-cljs | |
(:require [clojure.java.io :as io] | |
[cljs.compiler :as comp] | |
[cljs.analyzer :as ana])) | |
(defn read-file [file] | |
(let [eof (Object.)] | |
(with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))] | |
(vec (take-while #(not= % eof) | |
(repeatedly #(read stream false eof))))))) |
(defmacro def-curry-fn [name args & body] | |
{:pre [(not-any? #{'&} args)]} | |
(if (empty? args) | |
`(defn ~name ~args ~@body) | |
(let [rec-funcs (reduce (fn [l v] | |
`(letfn [(helper# | |
([] helper#) | |
([x#] (let [~v x#] ~l)) | |
([x# & rest#] (let [~v x#] | |
(apply (helper# x#) rest#))))] |
(ns sudoku | |
;(:refer-clojure :exclude [==]) | |
(:require-macros [cljs.core.logic.macros :as m]) | |
(:use [cljs.core.logic :only [everyg infd distinctfd]])) | |
(defn get-square [rows x y] | |
(for [x (range x (+ x 3)) | |
y (range y (+ y 3))] | |
(get-in rows [x y]))) |
(ns three.demo | |
(:require [THREE :as THREE])) | |
(def camera | |
(THREE/PerspectiveCamera. | |
75 | |
(/ 800 600) | |
1 | |
10000)) |
(ns async-test.sinewave.core | |
(:require [cljs.core.async :refer [<! >! chan timeout]]) | |
(:require-macros | |
[cljs.core.async.macros :as m :refer [go]])) | |
(defn sin-vals [offset] | |
(map #(Math/sin %) (iterate (partial + 0.1) offset))) | |
(let [events (chan)] |
Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
(by @andrestaltz)
So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).
Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:
Rx.Observable.prototype.flatMapLatest(selector, [thisArg])
Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
Kris Nuttycombe asks:
I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?
I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.
I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.
import struct | |
import spidev | |
import sys | |
import time | |
import random | |
import RPi.GPIO as gpio | |
ascii = [ | |
[ 0x55, 0x00, 0x55, 0x00, 0x55 ], | |
[ 0x55, 0x00, 0x55, 0x00, 0x55 ], |
Original text from http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.html
From: Mark Jason Dominus <[email protected]>
Date: Jul 28, 2005 11:16 PM
Subject: Re: HOP -vs- SICP