This file contains hidden or 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
| http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/ | |
| http://matt.might.net/articles/js-church/ | |
| https://en.wikipedia.org/wiki/Fixed-point_combinator | |
| http://www.cs.brown.edu/courses/cs173/2002/Lectures/2002-10-28-lc.pdf | |
| http://www.dsi.uniroma1.it/~labella/absMcAdam.ps | |
| http://www.cs.utexas.edu/users/wcook/Drafts/2009/sblp09-memo-mixins.pdf |
This file contains hidden or 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
| // Y combinator | |
| var Y = function (f) { | |
| return ( | |
| (function (x) { | |
| return f(function (v) { return x(x)(v); }); }) | |
| (function (x) { | |
| return f(function (v) { return x(x)(v); }); }) | |
| ); | |
| } |
This file contains hidden or 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
| Eshell V5.9.1 (abort with ^G) | |
| % The Y combinator allows recursion to be defined as a set of rewrite rules without requiring | |
| % native recursion support in the language. | |
| c(y_comb). % takes 2 params | |
| {ok,y_comb} | |
| (y_comb:y2( | |
| fun (R) -> | |
| fun |
This file contains hidden or 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
| Eshell V5.9.1 (abort with ^G) | |
| % The Y combinator allows recursion to be defined as a set of rewrite rules without requiring | |
| % native recursion support in the language. | |
| c(y_comb_single). % takes single param | |
| {ok,y_comb_single} | |
| (y_comb_single:y2( | |
| fun (F) -> | |
| fun(0) -> 1; |
This file contains hidden or 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
| Eshell V5.9.1 (abort with ^G) | |
| 1> c(mini_chat). | |
| {ok,mini_chat} | |
| 2> mini_chat:start(). | |
| true | |
| 3> Jane = spawn(mini_chat, user, ["Jane"]). | |
| SYSTEM: Jane has joined the channel. | |
| <0.42.0> | |
| 4> Zach = spawn(mini_chat, user, ["Zach"]). | |
| SYSTEM: Zach has joined the channel. |
This file contains hidden or 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 sudoku | |
| (:refer-clojure :exclude [==]) | |
| (:use clojure.core.logic)) | |
| (defn get-square [rows x y] | |
| (for [x (range x (+ x 3)) | |
| y (range y (+ y 3))] | |
| (get-in rows [x y]))) | |
| (defn init [vars hints] |
This file contains hidden or 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
| -module(mini_chat). | |
| -compile(export_all). | |
| -define(ACTIVE_OPTIONS, [{reuseaddr, true}]). | |
| % Commands start with "/", char 47 | |
| is_command(Str) -> hd(Str) =:= 47. | |
| chatroom(Users) -> | |
| process_flag(trap_exit, true), |
This file contains hidden or 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
| from pprint import pprint | |
| import random | |
| import sys | |
| def main(): | |
| aircraft_carrier = [] | |
| battle_ship = [] | |
| submarine = [] | |
| destroyer = [] |
This file contains hidden or 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
| push = (element) -> (stack) -> | |
| newStack = [element].concat stack | |
| {value: element, stack: newStack} | |
| pop = (stack) -> | |
| element = stack[0] | |
| newStack = stack.slice 1 | |
| {value: element, stack: newStack} | |
| bind = (stackOperation, continuation) -> (stack) -> |
NewerOlder