Last Update: May 13, 2019
Offline Version
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
what k4/k7 k9 example result | |
--------------------------------------------------------------------------------- | |
each-left a f\:b a f\:b (!3)*\:!2 (0 0;0 1;0 2) | |
each-right a f/:b a f/:b (!3)*/:!2 (0 0 0;0 1 2) | |
fold f/v f/v */6 7 42 | |
fold w/initial a f/v a f/v 7*/11 13 1001 | |
scan f\v f\v -\1 1 1 1 0 -1 | |
scan w/initial a f\v a f\v 3-\1 1 1 2 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
;;Shim class for running app without | |
;;aot compilation issues. | |
;;entrypoint for some gui. | |
(ns blah.main | |
(:gen-class :main true)) | |
;;This is the main entry point for the app. | |
;;It's a good example of a shim-class, and | |
;;requires some arcane features to get things | |
;;working to avoid aot compilation of dependent |
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 retry | |
(:import [java.util.function Supplier] | |
[java.util.concurrent CompletableFuture TimeUnit])) | |
(defn with-retry | |
"given an op wanting retries, and a strategy for backoff, | |
returns a CompletableFuture that can be waited on | |
op takes no args | |
A backoff strategy is a function of an exception, returning nil or a number of milliseconds to backoff" |
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
;; differences from scheme unfold | |
;; even initial value is lazy | |
;; predicate sense reversed | |
;; internal state == produced value, no special mapper-fn | |
;; no tail-gen | |
(defn series | |
"Produces a sequence of values. | |
`f` is a function that given a value, returns the next value. | |
`continue?` is a predicate that determines whether to produce |
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
#!/usr/bin/env escript | |
%%! -name rpc@127.0.0.1 | |
%% rpc is a script that connects to the given Erlang node using RPC and | |
%% evaluates an expression in it. | |
%% | |
%% Examples: | |
%% | |
%% rpc mynode@127.0.0.1 mycookie 'erlang:whereis(init)' | |
%% rpc mynode@127.0.0.1 mycookie erlang whereis '[init]' |
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 background | |
(:require [clojure.tools.logging :as log]) | |
(:import [java.util.concurrent])) | |
(defonce !executor (delay (java.util.concurrent.Executors/newCachedThreadPool))) | |
(defn background | |
"Calls the fn passed in a thread from a thread pool, returning immediately. | |
Unlike future, background does not swallow exceptions." | |
[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 todo-server.core | |
(:require | |
[cljs.nodejs :as nodejs] | |
[figwheel.client :as fw])) | |
(nodejs/enable-util-print!) | |
(defonce express (nodejs/require "express")) | |
(defonce serve-static (nodejs/require "serve-static")) | |
(defonce http (nodejs/require "http")) |
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
;; Example implementation of Norvig's Spellchecker in Clojure, | |
;; using core.async | |
;; | |
;; There are probably some bugs in this. | |
;; | |
;; Original problem: https://github.com/ericnormand/spelling-jam | |
;; from Lambda Jam, Chicago, 2013: http://lambdajam.com/ | |
;; | |
;; Clojure core.async introduction: | |
;; http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder