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
defmodule YCombinator do | |
@moduledoc """ | |
Some functions explaining the Y-Combinator. | |
Can definitely be improved upon, but this is as much as time allowed me this evening. | |
""" | |
def factorial(n) do | |
y_combinator(&almost_factorial/1).(n) |
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
*> Compile using GNU Cobol, e.g.: `cobc -x gcd_maxmin.cob` | |
IDENTIFICATION DIVISION. | |
PROGRAM-ID. gcd-maxmin. | |
ENVIRONMENT DIVISION. | |
DATA DIVISION. | |
WORKING-STORAGE SECTION. | |
01 NUMS. | |
05 NUMS-ELEMS PIC 9(9) | |
OCCURS 0 TO 9999 TIMES DEPENDING ON NUMS-LEN. | |
77 NUMS-IDX PIC 9(9) COMP. |
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(caesar_cipher, [ | |
shift_plaintext_cyphertext/3, | |
shift_plainchar_cypherchar/3, | |
shift_plainletter_cypherletter/3 | |
]). | |
:- use_module(library(reif)). | |
:- use_module(library(clpz)). | |
:- use_module(library(lists)). |
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
{:beam_file, Addition, | |
[ | |
{:__info__, 1, 2}, | |
{:"__type_check_spec_for_add/2__", 0, 18}, | |
{:add, 2, 8}, | |
{:baseline_add, 2, 16}, | |
{:module_info, 0, 20}, | |
{:module_info, 1, 22} | |
], [vsn: [337339698024769425821845159222917769638]], | |
[ |
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
defmodule Capturepipe do | |
@doc """ | |
A pipe-operator that extends the normal pipe | |
in one tiny way: | |
It allows the syntax of having a bare `&1` capture | |
to exist inside a datastructure as one of the pipe results. | |
This is useful to insert the pipe's results into a datastructure | |
such as a tuple. |
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
defmodule Capturepipe do | |
@doc """ | |
A pipe-operator that extends the normal pipe | |
in one tiny way: | |
It allows the syntax of having a bare `&1` capture | |
to exist inside a datastructure as one of the pipe results. | |
This is useful to insert the pipe's results into a datastructure | |
such as a tuple. |
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
# See https://github.com/elixir-lang/elixir/blob/master/lib/elixir/src/elixir_parser.yrl#L52 | |
# for the list of operators with associativity, etc. | |
# The operators in this list are grouped by precedence, low to high. | |
# The comments indicate the operator's normal function, as well as its ability to be defined/overridden. | |
-> # CompileError 'unhandled operator'. only allowed in anonymous function syntax. | |
& # CompileError, only allowed in short anonymous function syntax. |
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
#include <iostream> | |
#include <vector> | |
auto continuation = [](auto && val){return [=](auto && cont) { return cont(val);};}; | |
auto style = [](const auto &val) { return val; }; | |
auto mod = [](auto &&modv) { return [=](auto &&truecont){ return [=](auto &&falsecont) { return [=](auto &&val) { if (val % modv) { return truecont(val); } else { return falsecont(val); }; }; }; }; }; | |
auto passing = [](auto &&val) { return [=](auto &&cont){ return [=](auto &&) {return cont(val);};};}; | |
bool isLeapYear(int year){ | |
return (continuation) |
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
{-# LANGUAGE DataKinds, KindSignatures, TypeFamilies, PolyKinds, GADTs #-} | |
module Example where | |
import qualified Control.Arrow | |
import qualified Prelude | |
import Prelude hiding (id, (.)) | |
import qualified Control.Category | |
-- | Example type: A Qfun is a function with a Quality: Either 'Good' or 'Bad'. |
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
function base64ImageUploader(dialog) { | |
var reader, image_url, img; | |
var canvas = document.createElement("canvas"); | |
var canvas_context = canvas.getContext('2d'); | |
function rotateImage(direction){ | |
//These are swapped when rotating |