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
// | |
// Description: A Scala implementation of a parser for integer literals | |
// | |
package string2int | |
// The states of the parser | |
enum State { case START, ZERO, DEC, OCT, B, BIN, X, HEX, ERROR } | |
import State._ |
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
void setup() { | |
size(500, 500); | |
noLoop(); | |
} | |
void draw() { | |
stroke(#ffffff); | |
strokeWeight(20); | |
snow(width/2, height/2, 0.8 * min(width, height)); | |
} |
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
void setup() { | |
size(500, 500); | |
noLoop(); | |
} | |
void draw() { | |
translate(width/2, 0.9 * height); | |
scale(1, -1); | |
tree(0.8 * height, 5); | |
} |
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
color trunkcolor = #663300; | |
color leafcolor = #00AA00; | |
class Crystal { | |
float x, y, phi; | |
Crystal(float x0, float y0, float phi0) { | |
x = x0; y = y0; phi = phi0; | |
} | |
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
from collections.abc import Mapping, MutableMapping | |
class Table(MutableMapping): | |
def __init__(self): | |
self.__table = [] # the internal table as a list of key-value pairs | |
def __len__(self): | |
return len(self.__table) | |
def __str__(self): |
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
size(800, 400); | |
colorMode(HSB, 360.0, 1.0, 1.0, 1.0); | |
// The sky by the perlin noise | |
for (int i = 0; i < width; i++) { | |
for (int j = 0; j < height; j++) { | |
stroke(210, noise(0.005 * i, 0.005 * j), 1.0); | |
point(i, j); | |
} | |
} |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <ctype.h> | |
int e_atoi(char *str) { | |
enum { ST_START, ST_ZERO, ST_DEC, ST_OCT, ST_X, ST_HEX } state = ST_START; | |
int result = 0; | |
for (int c = *(str++); c != '\0'; c = *(str++)) { | |
switch (state) { |
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 java.io.Reader; | |
import java.io.StringReader; | |
import java.io.IOException; | |
import static java.lang.Character.isDigit; | |
enum State { START, ZERO, DEC, OCT, X, HEX } | |
public class String2int { | |
public static int string2int(String digits) { | |
return (int)string2long(digits); |
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 java.util.*; | |
public class HashTable<K, V> extends AbstractMap<K, V> { | |
protected SimpleEntry<K, V>[] table_; | |
protected int count_ = 0; | |
private HashTable<K, V> self = this; | |
public HashTable(int n) { | |
table_ = (SimpleEntry<K, V>[])new SimpleEntry[n]; | |
} |
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 scala.collection.mutable | |
class HashTable[K, V](n: Int) extends mutable.AbstractMap[K, V] { | |
protected var table = mutable.ArraySeq.fill(n)(Nil:List[(K, V)]) | |
protected var count = 0 | |
def this() = this(10) | |
override def size: Int = count |
NewerOlder