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
(def summaries ["cold" "moderate"]) ;; creates a vector with two strings: "cold" and "moderate" | |
(def new-summaries (assoc summaries 2 "hot")) ;; creates a new vector with an additional string: "hot" | |
(def old-names {:c "celsius" }) ;; creates a map from keywords to strings | |
(def names (assoc old-names {:f "farenheit"})) ;; creates a new map with additional entry | |
(defn celsius->farenheit [c] ;; define a function that converts from celsius to farenheit | |
(+ 32 (* c 9/5))) ;; c * 9/5 + 32 | |
(defn celsius->summary [c] ;; define a function that converts from celsius to summary |
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
;; gorilla-repl.fileformat = 1 | |
;; ** | |
;;; | |
;; ** | |
;; @@ | |
(ns gains | |
(:require [gorilla-plot.core :as plot] | |
[gadjett.collections :refer [map-object]] |
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
(defn transparent [arg] | |
[(type arg) (meta arg) (when (seq? arg) (seq arg)) arg]) | |
(defn memoize-tr | |
"Returns a memoized version of a function (even if it is not referentially | |
transparent). The memoized version of the function keeps a cache of the | |
mapping from arguments to results and, when calls with the same arguments | |
are repeated often, has higher performance at the expense of higher memory use." | |
{:added "1.0" |
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
(labels ((factorial (n) | |
(if (= n 0) | |
1 | |
(* n (factorial (- n 1)))))) | |
(factorial 5)) |
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
let rec sigma (f, s) = | |
switch (s) { | |
| [] => 0 | |
| [x, ...l] => f (x) + sigma (f, l) | |
}; | |
let a = sigma ((fun (x) => x * x), [1, 2, 3]); |
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
(require '[reagent.core :as reagent]) | |
(def styles {:style {:color "red"}}) | |
(defn hello [] | |
[:div styles | |
"Hello CSS"]) | |
(reagent/render [hello] js/klipse-container) |
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
let rec sigma (f, s) = | |
switch (s) { | |
| [] => 0 | |
| [x, ...l] => f (x) + sigma (f, l) | |
}; | |
let () = Js.log (sigma ((fun (x) => x * x), [1, 2, 3])); |
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
let rec sigma f s => | |
switch s { | |
| [] => 0 | |
| [x, ...l] => f x + sigma f l | |
}; | |
let () = Js.log (sigma (fun x => x * x) [1, 2, 3]); |
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
let rec sigma f = function | |
| [] -> 0 | |
| x :: l -> f x + sigma f l;; | |
Js.log (sigma (fun x -> x * x) [1; 2; 3]);; |
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
class MyCanvas extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = {value: ''} | |
this.handleClick = this.handleClick.bind(this) | |
} | |
componentDidMount() { | |
this.render() |