Skip to content

Instantly share code, notes, and snippets.

View ELLIOTTCABLE's full-sized avatar
🐫

ELLIOTTCABLE

🐫
View GitHub Profile
@ELLIOTTCABLE
ELLIOTTCABLE / gist:264034
Created December 26, 2009 20:31 — forked from atg/gist:264032
foo = routine
lookup = routine
# All lookups after foo are put into @
# so 'foo bar baz' would give you @ = (bar baz)
out = @0
# The default implementation does a reduce() with dereferencing, something like this
@.prepend(this)
reduce(@0)
@2(@0[@1])
out(@0)
def what_is_gist
Sex::Pure
end
my.strings ↼ ~‘foo,’ ‘bar,’ ‘baz’
my.strings each
print(argument)
mathematics
I/O STDIN
“Trabb-Pardo Knuth”
r ↼ routine
mathematics √(mathematics absolute.value(argument last)) + 5 × argument last ³
11 times { I/O STDIN get.string } reverse each
n ↼ r(argument)
void display(int x[BOARD_WIDTH][BOARD_HEIGHT]) {
printf(" 1 2 3 4 5 6 7\n\n");
for (int i = 0; i < BOARD_HEIGHT; ++i) {
printf("%d ", i + 1);
for (int j = 0; j < BOARD_WIDTH; ++j)
if (x[j][i] >= (int)'0')
printf("%c ", (char)(x[j][i] + (int)'0'));
// A Javascript version of Allan Odgaard's thousands separator regex
// http://blog.macromates.com/2007/recursion-in-regular-expressions/
123456789.toString().replace(/(\d{1,3})(?=(\d{3})+(?!\d))/g, '$1,');
// => "123,456,789"
#!/usr/bin/ruby
#
# Download and execute this script in one-line with no temporary files:
#
# ruby -e "$(curl http://gist.github.com/raw/323731/install_homebrew.rb)"
#
#
# I deliberately didn't DRY /usr/local references into a variable as this
# script will not "just work" if you change the destination directory. However
# please feel free to fork it and make that possible.
(defclass rock ()())
(defclass paper ()())
(defclass scissors ()())
(defgeneric r-p-s (a b))
(defmethod r-p-s ((r rock) (p paper)) 'paper)
(defmethod r-p-s ((r rock) (s scissors)) 'rock)
(defmethod r-p-s ((p paper) (s scissors)) 'scissors)
request ↼ server listen()
print("how many times is this printed", request address, request port)
#--------
display ↼ routine { print("how many times is this printed", @ address, @ port) }
request ↼ server listen()
display(request)
“Either:”
test ↼ { @ fork; print("hi."); print(@); print("hi again."); }
a ↼ b each
test(a)
“Or:”
test ↼ { print("hi.", @, "hi again."); }