Применить функцию к каждому элементу списка - это просто:
map _ [] = []
map f (x:xs) = f x : map f xs
x ∈ Λ; Лямбда-выражения строятся из переменных | |
M, N ∈ Λ ⇒ λx.M ∈ Λ ∧ M N ∈ Λ; с помощью абстракций и аппликаций; | |
(M) = M, M N P = (M N) P. причем аппликация лево-ассоциативна. | |
x[x := P] = P; Подстановка заменяет вхождения переменной на другое выражение, | |
y[x := P] = y; но только если переменная совпадает, | |
(λx.M)[x := P] = λx.M; при этом связанные переменные не подлежат подстановке; | |
(λy.M)[x := P] = λy.M[x := P]; операция подстановки через абстракции | |
(M N)[x := P] = M[x := P] N[x := P]. и аппликации проходит выражение рекуррентно. |
Delimited continuations manipulate the control flow of programs. Similar to control structures like conditionals or loops they allow to deviate from a sequential flow of control.
We use exception handling as another example for control flow manipulation and later show how to implement it using delimited continuations. Finally, we show that nondeterminism can also be expressed using delimited continuations.
#!/bin/bash | |
[ -f /usr/bin/gcc ] || (apt-get update && apt-get install -y build-essential libncurses-dev libssl-dev chrpath) | |
#wget http://www.hpl.hp.com/research/linux/atomic_ops/download/libatomic_ops-7.2d.tar.gz | |
#tar zxf libatomic_ops-7.2d.tar.gz | |
#cd libatomic_ops-7.2/ | |
#./configure --prefix=/opt/flussonic | |
#make install | |
#cd .. |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
defmodule XmlNode do | |
require Record | |
Record.defrecord :xmlAttribute, Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl") | |
Record.defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl") | |
def from_string(xml_string, options \\ [quiet: true]) do | |
{doc, []} = | |
xml_string | |
|> :binary.bin_to_list | |
|> :xmerl_scan.string(options) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Basic unit type:
λ> replTy "()"
() :: ()
Basic functions: