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
macro_rules! cond { | |
($($e:expr => $body:expr),+, _ => $default:expr) => ( | |
$(if $e { $body } else)+ { $default } | |
); | |
($e:expr => $body:expr) => ( if $e { $body }) | |
} | |
fn main() { | |
let age = 25; |
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
Array.prototype.pick = function(index) { | |
let element = this.splice(index, 1) | |
if (element == null || element.length == 0) { | |
return undefined | |
} | |
return element[0] | |
} |
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 Control.Monad.Trans.State | |
data Expression = Var Char | |
| Const Int | |
| Expression :+: Expression | |
| Int :*: Expression | |
deriving (Eq, Ord, Show) | |
type Context = State (Maybe Expression) |
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
show() { | |
for file in $(find .); do | |
if [[ $file =~ $1 || $file == $1 ]]; then | |
echo $file | |
fi | |
done | |
} |
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
cleanup() { | |
count=0 | |
filename=$1 | |
for file in $(find .); do | |
if [ -f $file ] && [[ $file =~ $filename || $file == $filename ]]; then | |
let "count++" | |
fi | |
done |
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
// modulo operation that behaves correctly with negative numbers | |
function mod(n, m) { | |
return ((n % m) + m) % m; | |
} | |
// converts a character to its digit representation | |
// same as indexOf, but more succinct | |
function toDigit(char, alphabet) { | |
return alphabet.indexOf(char) | |
} |
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
#![feature(box_patterns)] | |
use std::fmt; | |
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Clone)] | |
enum Tree<T: fmt::Display> { | |
Leaf, | |
Node { data: T, left: Box<Tree<T>>, right: Box<Tree<T>> }, | |
} | |
impl<T: fmt::Display> fmt::Display for Tree<T> { |
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
function touch-cpp { | |
for file in "$@" | |
do | |
cpp="$file.cpp" | |
hpp="$file.hpp" | |
# only actually attempt to write the files if they don't exist. | |
if [ -f $cpp -o -f $hpp ] | |
then | |
echo ">> Either $cpp or $hpp already exist, no action taken." |
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
package eu.wausoft.city.gen | |
import scala.util.Random | |
import java.io._ | |
/** | |
* Created by coffee on 3/8/16. | |
*/ | |
object Generator { | |
val prefixes = Vector ( | |
"Alt", "Alten", "Olden", "Groß", "Großen", "Hoh", "Hohen", |
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
package eu.wausoft.lex | |
import java.lang.{String => JString} // renames the built-in string to JString to avoid token clashing | |
trait Token | |
case class String(value: JString) extends Token | |
case class Number(value: JString) extends Token | |
case class Atom(value: JString) extends Token | |
case class Keyword(value: JString) extends Token | |
case object Unknown extends Token |