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* ((....)) | |
;;; receive : channel0 -> pair term channel1 | |
;;; send : channel0 -> term -> channel1 | |
(lambda (receive send channel) | |
(let ((loop (Y (lambda (loop channel0)) | |
(let* ((result (receive channel0)) | |
(sexp (first result)) | |
(channel1 (second result)) | |
(term (extract sexp)) | |
(normal (reduce normal-order term)) |
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* ((fold-term | |
(lambda (var-folder abs-folder app-folder term) | |
(cond ((var? term) | |
(var-folder (var/get-id term))) | |
((abs? term) | |
(abs-folder (abs/get-id term) (abs/get-body term))) | |
((app? term) | |
(app-folder (app/get-left term) (app/get-right term)))))) | |
(free? |
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* ((true (lambda (true false) true)) | |
(false (lambda (true false) false)) | |
(and (lambda (pred1 pred2) (pred1 pred2 pred1))) | |
(if (lambda (pred true-clause false-clause) (pred true-clause false-clause))) | |
(fix (lambda (g) ((lambda (x) (g (x x))) (lambda (x) (g (x x)))))) | |
(pair (lambda (first second pair) (pair first second))) | |
(first (lambda (pair) (pair true))) | |
(second (lambda (pair) (pair false))) |
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 | |
identity same = same | |
const always _any = always | |
true = const | |
false = const identity | |
pair first second pair = pair first second | |
first pair = pair true | |
second pair = pair false |
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* ((identity (lambda (same) same)) | |
(const (lambda (always _any) always)) | |
(true const) | |
(false (const identity)) | |
(pair (lambda (first second pair) (pair first second))) | |
(first (lambda (pair) (pair true))) | |
(second (lambda (pair) (pair false))) |
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
$ stack exec abstract samples/4-nested-let.scm | |
λ > (0 → (+1 → (+ → (* → (^ → (1 → (2 → (^ 2) 2) ((+ 1) 1)) (+1 0)) (num1 num2 → num2 num1)) (num1 num2 succ zero → (num1 (num2 succ)) zero)) (num1 num2 succ zero → (num1 succ) (num2 succ) zero)) (num succ zero → succ ((num succ) zero))) (succ zero → zero) | |
β > (+1 → (+ → (* → (^ → (1 → (2 → (^ 2) 2) ((+ 1) 1)) (+1 (succ$109 zero$110 → zero$110))) (num1 num2 → num2 num1)) (num1$48 num2$49 succ zero → (num1$48 (num2$49 succ)) zero)) (num1$68 num2$69 succ$70 zero$71 → (num1$68 succ$70) (num2$69 succ$70) zero$71)) (num succ$92 zero$93 → succ$92 ((num succ$92) zero$93)) | |
β > (+ → (* → (^ → (1 → (2 → (^ 2) 2) ((+ 1) 1)) ((num succ$92 zero$93 → succ$92 ((num succ$92) zero$93)) (succ$109 zero$110 → zero$110))) (num1 num2 → num2 num1)) (num1$48 num2$49 succ zero → (num1$48 (num2$49 succ)) zero)) (num1$68 num2$69 succ$70 zero$71 → (num1$68 succ$70) (num2$69 succ$70) zero$71) | |
β > (* → (^ → (1 → (2 → (^ 2) 2) (((num1$68 num2$69 succ$70 zero$71 → (num1$68 succ$70) (num2$69 suc |
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
changeset = | |
ProviderSelection.upsert_changeset(%{ | |
entity_id: entity_id, | |
entity_type: entity_type, | |
provider: provider | |
}) | |
set_values = | |
changeset.changes | |
|> Keyword.new() |
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
module Lamb where | |
import Prelude hiding (read, succ) | |
import qualified Prelude (read) | |
import qualified Data.Char as Char | |
import qualified System.Console.Readline as Readline | |
operator_chars = "=+-*/" |
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 | |
id = same => | |
same | |
const = always _ => | |
always |
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 ((true (lambda (true false) true)) | |
(false (lambda (true false) false)) | |
(and (lambda (pred1 pred2) (pred1 pred2 pred1))) | |
(if (lambda (pred true false) (pred true false))) | |
(+1 (lambda (num succ zero) (succ (num succ zero)))) | |
(+ (lambda (num1 num2 succ zero) (num1 succ (num2 succ zero)))) | |
(* (lambda (num1 num2 succ zero) (num1 (num2 succ) zero))) | |
(^ (lambda (num1 num2) (num2 num1))) | |
(-1 (lambda (num succ pred) | |
(num (lambda (g h) (h (g succ))) |