Skip to content

Instantly share code, notes, and snippets.

View olabini's full-sized avatar

Ola Bini olabini

View GitHub Profile
@olabini
olabini / phone_number.ik
Created July 26, 2011 16:13
Phone number coding program in Ioke
List splitAt = method(n, [self[0...n], self[n..-1]])
PhoneNumbers = Origin mimic do(
words = FileSystem readFully("/usr/share/dict/words") split("\n")
mnemonics = {
2 => "ABC",
3 => "DEF",
4 => "GHI",
5 => "JKL",
6 => "MNO",
GameOfLife = Origin mimic do(
initialize = method(rows:, columns:,
@grid = Grid withDimensions(rows, columns))
evolve = method(
nextGrid = grid blankGrid
grid filter(numLiveNeighbours in?(2..3)) each(cellInfo, nextGrid spawnCell(cellInfo coords first, cellInfo coords second))
@grid = nextGrid
)
counts = method(
files_to_read = FileSystem["**"] reject(name, FileSystem directory?(name))
combined_text = files_to_read map(filename, FileSystem readFully(filename)) join("")
filtered_words = #/\w+/ allMatches(combined_text) map(lower)
filtered_words inject({} withDefault(0), counts, word, counts[word]++. counts)
)
spit = method(outfile, enumerable,
FileSystem withOpenFile(outfile, fn(file, enumerable each(x, file println(x)))))
Position = Origin mimic do(
at = method(x, y, with(x: x, y: y))
origin = at(0, 0)
+ = method(position, at(x + position x, y + position y))
asText = method("(#{x},#{y})")
)
at = method(x, y, Position at(x,y))
; This is pretty funny, right?
INFO] [jar:jar]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/olabini/workspace/cuke4duke/examples/java/target/cuke4duke-java-example-0.1.6.jar
[INFO] [cuke4duke:cucumber {execution: run-features}]
[INFO] Code:
[INFO]
[INFO] Features:
[INFO] * features/call_step.feature
[INFO] * features/demo.feature
[INFO] * features/hooks.feature
Then = Origin mimic
Then allThens = []
Then match = method(inputText,
allThens each(th,
if(th pattern =~ inputText,
th code call(*(it names map(nm, it[nm]))))))
then = dmacro(
[>pattern, code]
messages = pattern names map(nm,
import(:javax:swing, :JFrame, :JButton)
import java:awt:GridLayout
button = JButton new("Press me!") do(
addActionListener(fn(e, button text = "Hello from Ioke")))
JFrame new("My Frame") do(
layout = GridLayout new(2, 2, 3, 3)
add(button)
setSize(300, 80)
public interface SimpleInterface {
public String doSomething();
}// SimpleInterface