Boolean combinators
In the Clojure Tip above, I described a kind of Boolean combinator that lets us build complex rules out of simpler rules. Your task is to build those combinators. Please define:
(defn rule-and
([])
([rule])
import java.lang.reflect.Field; | |
import java.lang.reflect.Modifier; | |
import java.util.Random; | |
/** | |
* General fuckery. | |
* | |
* @author jezza | |
* @date Oct 1, 2015 | |
*/ |
import static java.lang.invoke.MethodHandles.lookup; | |
import static java.lang.invoke.MethodType.methodType; | |
import java.lang.invoke.MethodHandle; | |
import java.lang.invoke.MethodHandles; | |
import java.lang.invoke.MethodHandles.Lookup; | |
import java.lang.invoke.MethodType; | |
import java.lang.invoke.MutableCallSite; | |
import java.util.Arrays; |
(ns ants.core) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) 2008 Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. |
Boolean combinators
In the Clojure Tip above, I described a kind of Boolean combinator that lets us build complex rules out of simpler rules. Your task is to build those combinators. Please define:
(defn rule-and
([])
([rule])
;; source code related to the project shown in this video: | |
;; https://youtu.be/_XiEc0g2wL8 | |
;; author: adam-james | |
(ns hc.main) | |
(defn hiccup? | |
[item] | |
(and (vector? item) | |
(keyword? (first item)))) |
(defn contextual-eval [ctx expr] | |
(eval | |
`(let [~@(mapcat (fn [[k v]] [k `'~v]) ctx)] | |
~expr))) | |
(defmacro local-context [] | |
(let [symbols (keys &env)] | |
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols))) | |
(defn readr [prompt exit-code] | |
(let [input (clojure.main/repl-read prompt exit-code)] | |
(if (= input ::tl) |
Racing the Beam: The Atari Video Computer System
This is the book that got me excited about emulation and got me thinking about some of these computers in general.
Koji Kondo's Super Mario Bros. Soundtrack
I read this around the same time. It talks at length about the audio capabilities of the NES, which I haven't touched on here but are interesting and influential!
(ns graph) | |
(def graph | |
{:A {:children #{:E :B} | |
:population 200 | |
:id :A} | |
:B {:children #{:A :C :E} | |
:population 300 | |
:id :B} | |
:C {:children #{:B :D} |
A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.
How to use: