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
(def lang1-parser | |
(instaparse.core/parser | |
"prog = (spaces? expr spaces? <';'> spaces?)* | |
<expr> = assig | add-sub | |
assig = varname spaces? <'='> spaces? expr | |
<add-sub> = mult-div | add | sub | |
add = add-sub spaces? <'+'> spaces? mult-div | |
sub = add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = factor | mult |div | |
mult = mult-div spaces? <'*'> spaces? factor |
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
(def lang0-parser | |
(instaparse.core/parser | |
"prog = (spaces? expr spaces? <';'> spaces?)* | |
<expr> = assig | add-sub | |
assig = varname spaces? <'='> spaces? expr | |
<add-sub> = mult-div | add | sub | |
add = add-sub spaces? <'+'> spaces? mult-div | |
sub = add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = factor | mult |div | |
mult = mult-div spaces? <'*'> spaces? factor |
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
(def arith-parser | |
(instaparse.core/parser | |
"prog = spaces? add-sub spaces? | |
<add-sub> = mult-div | add | sub | |
add = add-sub spaces? <'+'> spaces? mult-div | |
sub = add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = term | mult | div | |
mult = mult-div spaces? <'*'> spaces? term | |
div = mult-div spaces? <'/'> spaces? term | |
<term> = number | <'('> add-sub <')'> |
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
(def addmult-parser | |
(instaparse.core/parser | |
"prog= spaces? add-sub spaces? | |
<add-sub> = mult-div | add | sub | |
add= add-sub spaces? <'+'> spaces? mult-div | |
sub= add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = number | mult | div | |
mult= mult-div spaces? <'*'> spaces? number | |
div= mult-div spaces? <'/'> spaces? number | |
number= #'-?[0-9]+' |
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
(def addsub-parser | |
(instaparse.core/parser | |
"prog= spaces? add-sub spaces? | |
<add-sub> = number | add | sub | |
add= add-sub spaces? <'+'> spaces? number | |
sub= add-sub spaces? <'-'> spaces? number | |
number= #'-?[0-9]+' | |
<spaces> = <#'\\s+'>")) |
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
(def const-parser | |
(instaparse.core/parser | |
"prog= spaces? number spaces? | |
number=#'-?[0-9]+' | |
<spaces> = <#'[\\s]'+>")) | |
(const-parser " -123456 ") |
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
public static void swap(int[] data, int i, int j){ | |
int tmp= data[i]; | |
data[i]= data[j]; | |
data[j]= tmp; | |
} | |
public static int partition(int[] data, int begin, int end, int pivotIdx){ | |
swap(data, pivotIdx, --end); | |
pivotIdx= end; | |
int pivot= data[pivotIdx]; |
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
(ns kingdomino.core | |
(:require [instaparse.core :as insta]) | |
(:gen-class)) | |
(def size 100) | |
(def delta-sides 5) | |
(def ncols 2) | |
(def delta-dominos 10) | |
(def colors {:clay "#cc6600" :field "#ffff66" :water "#33ccff" :pasture "#00cc00" :forest "#669900" :mine "#5c5c3d"}) |
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 <tuple> | |
#include <cmath> | |
#include <cstdlib> | |
#include <iterator> | |
#include <vector> | |
#include <algorithm> | |
#include <string> | |
// STEPS=100;for i in $(seq $((3 * $STEPS)) $((8 * $STEPS))); do ./chaos-polygons $(bc -l <<< "scale=2;$i / $STEPS") > generated-cmax-100-$i.pgm; done | |
// for i in generated-cmax-100-*.pgm; do convert $i ${i%.pgm}.png; done |
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
(ns clojr.core | |
(:require [instaparse.core :as insta]) | |
(:import (clojure.lang DynamicClassLoader))) | |
(import '[clojure.asm ClassWriter Type Opcodes] | |
'[clojure.asm.commons Method GeneratorAdapter]) | |
(def parser | |
(insta/parser | |
"prog = expr (<#'[\\n]+'> expr?)* |
NewerOlder