This file contains 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
// A lazy sequence is an object that has several methods: an API. | |
// A star function RETURNS a lazy sequence: | |
const naturals = function* () { | |
let i = 1; | |
while (true) { // infinite loop generates an infinite sequence! | |
yield i++; | |
} | |
}; |
This file contains 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 hello.core | |
(:require [om.next :as om :refer-macros [defui]])) | |
(enable-console-print!) | |
(def React (js/require "react-native")) | |
(def AppRegistry (aget React "AppRegistry")) | |
(def StyleSheet (aget React "StyleSheet")) | |
(def create-element (aget React "createElement")) |
This file contains 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
import Time (every) | |
import Window (dimensions) | |
firstImageIndex = 0 | |
lastImageIndex = 1000 | |
delta = lift inSeconds (fps 30) | |
modCount signal period = lift (\a -> a `mod` period) (count signal) | |
data PlayDirection = Fwd | Back |
This file contains 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
#lang racket | |
(require plot) | |
(require plot/utils) | |
(define (plot-zeros-to-file xy-function file-name epsilon) | |
(parameterize ([plot-x-axis? #f] | |
[plot-x-label #f] | |
[plot-x-far-axis? #f] | |
[plot-y-axis? #f] | |
[plot-y-label #f] |
This file contains 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 breaking-dollars) | |
(defn first-coin-choices [cents denominations already-chosen] | |
(let [possible-choices (filter #(<= % cents) denominations)] | |
(if (empty? already-chosen) | |
possible-choices | |
; choose descending order to eliminate permutations: | |
(filter #(<= % (last already-chosen)) possible-choices)))) | |
This file contains 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 ex5.map-while-spec | |
(:use ex5.map-while) | |
(:use clojure.test)) | |
(deftest test-map-while-1 | |
(let [f #(* % %) | |
s (range 100) | |
pred #(< % 50) | |
result (map-while-1 f s pred)] | |
(is (= (count result) 50)) |
This file contains 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 account | |
(:import [java.util Date] | |
[java.lang Math]) | |
(:use [util])) | |
(def account-type [:checking :savings :money-market]) | |
(def interest-rate (zipmap account-type [0.02 0.04 0.06])) | |
(def overdraft-charge (zipmap account-type [0.10 0.075 0.05])) |
This file contains 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 rovers | |
(:use [clojure.string :only [split-lines]])) | |
(def *test-input* | |
"5 5 | |
1 2 N | |
LMLMLMLMM | |
3 3 E | |
MMRMMRMRRM") |
This file contains 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
(import '(java.awt.image BufferedImage)) | |
(import '(javax.imageio ImageIO IIOImage)) | |
(import '(javax.imageio.stream FileImageOutputStream)) | |
(import '(com.sun.imageio.plugins.png PNGMetadata PNGImageReader)) | |
(import '(java.io ByteArrayOutputStream File)) | |
;; See the following document for requirements | |
;; for upper- and lower-case letters in the four-letter chunk name: | |
;; http://en.wikipedia.org/wiki/Portable_Network_Graphics#.22Chunks.22_within_the_file | |
(def generator-chunk-name "gnTr") |
This file contains 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
private var _selectedMetric:Metric; | |
[Bindable] | |
public function get selectedMetric():Metric | |
{ | |
return _selectedMetric; | |
} | |
public function set selectedMetric(value:Metric):void | |
{ |
NewerOlder