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
defmodule Parser do | |
def parse(source) do | |
source |> Code.string_to_quoted!() | |
end | |
def parse_to_expr(source) do | |
source |> parse |> to_expr | |
end | |
def to_expr({:+, _, [a, b]}) do |
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
defmodule Expr do | |
@moduledoc """ | |
A simple expression parser & evaluator. | |
To use it, call run/1: | |
iex> Expr.run "1*2*3*4*5+1000" | |
1120 | |
It also supports let bindings: |
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
use Phoenix.Controller, namespace: HelloWeb | |
import Plug.Conn | |
import HelloWeb.Router.Helpers | |
import HelloWeb.Gettext |
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
defmodule HelloWeb do | |
def controller do | |
quote do | |
use Phoenix.Controller, namespace: HelloWeb | |
import Plug.Conn | |
import HelloWeb.Router.Helpers | |
import HelloWeb.Gettext | |
end | |
end |
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 Main where | |
fizzBuzz :: Int -> IO () | |
fizzBuzz n | n `mod` 5 == 0 && n `mod` 3 == 0 = putStrLn "Fizz Buzz" | |
| n `mod` 5 == 0 = putStrLn "Buzz" | |
| n `mod` 3 == 0 = putStrLn "Buzz" | |
| otherwise = return () | |
runManyActions [] = return [] | |
runManyActions (x:xs) = do |
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
timestamp=$(date +%y%m%d) | |
folder="~/.today" | |
eval folder=$folder | |
mkdir $folder -p | |
file="~/.today/$timestamp.txt" | |
eval file=$file | |
touch $file |
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
#!/usr/bin/bash | |
INSTALLER_VERSION=2.0 | |
CNCHI_VERSION=0.6.11 | |
TEXTDOMAIN=cli_installer | |
# we rely on some output which is parsed in english! | |
#unset LANG | |
source /etc/antergos/functions | |
ANSWER="/tmp/.setup" |
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
import Data.List (find, isPrefixOf) | |
data Syllab = Syllab { findStr :: String, replaceStr :: String } | |
deriving Show | |
appliesTo string syllab = isPrefixOf (findStr syllab) string | |
vocabulary = [Syllab "cho" "tio", | |
Syllab "nho" "neo", | |
Syllab "rr" "r", |
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
defmodule Parbool do | |
require Process | |
def or_(task1, task2) do | |
parent = self | |
pid1 = spawn(fn -> send parent, task1.() end) | |
pid2 = spawn(fn -> send parent, task2.() end) | |
receive do | |
false -> | |
receive do | |
result2 -> |
NewerOlder