Skip to content

Instantly share code, notes, and snippets.

View briantrice's full-sized avatar

Brian T. Rice briantrice

View GitHub Profile
@briantrice
briantrice / cross-product.slate
Created September 18, 2012 03:34
A stupid-simple cross-product for collections
collections define: #CrossProduct &slots: {#rows -> #{}. #columns -> #{}}.
c@(Collection traits) <*> d@(Collection traits)
[
CrossProduct new `>> [rows := c. columns := d. ]
].
cross@(CrossProduct traits) do: block
[
c do: [| :a |
@briantrice
briantrice / gist:1687405
Created January 27, 2012 06:26
Boom (not the good kind)
➜ atomy git:(master) ✗ atomy
when loading /Users/briantrice/.rvm/gems/rbx-head/gems/atomy-0.2/kernel/boot.ay...
An exception occurred running /Users/briantrice/.rvm/gems/rbx-head/bin/atomy
undefined method `each' on nil:NilClass. (NoMethodError)
Backtrace:
Kernel(NilClass)#each (method_missing) at kernel/delta/kernel.rb:81
Rubinius::AST::Container(Atomy::AST::Script)#container_bytecode at \
/Users/briantrice/.rvm/rubies/rbx-head/runtime/19/compiler/ast/definitions.rbc:945
Atomy::AST::Script#bytecode at /Users/briantrice/.rvm/gems/rbx-head
@briantrice
briantrice / gist:1687188
Created January 27, 2012 05:30
Wait, what?
➜ atomy git:(master) ✗ atomy
An exception occurred running /Users/briantrice/.rvm/gems/ruby-1.9.2-p290/bin/atomy
undefined method `ruby19?' on Rubinius (Module) (NoMethodError)
Backtrace:
Kernel(Module)#ruby19? (method_missing) at kernel/delta/kernel.rb:79
Object#__script__ at /Users/briantrice/.rvm/gems
/ruby-1.9.2-p290/gems
/atomy-0.2/bin/atomy:4
Kernel(Object)#load at kernel/common/kernel.rb:732
@briantrice
briantrice / CompactLookupTable.st
Created April 12, 2011 22:44
A version of Rubinius' CompactLookupTable for Slate
define: #CompactMapping &parents: {Collection. Mapping} &slots: {
#contents -> #{}
}.
m@(CompactMapping traits) new*
[| *rest |
m new `>> [contents := rest. ]
].
m@(CompactMapping traits) size
Syntax
* DONE Bootstrap in :=. :macro:global:
* DONE Allow | as a binary selector character.
* STARTED Bootstrap in ::= binding. :macro:global:
* TODO Implement mutator selector pattern of "foo:=" and sunset "foo:". :global:
* TODO Externalize `setTo: rules into data structures.
* TODO Implement Ruby === for includes:/select:/case-statement usage. :vm:support:
With different assymetrical selector, e.g. isCaseOf:.
Root -> \=. Collection -> includes:, Block -> applyWith:. Regex -> matches:.
* TODO Implement \=:= as pattern-matching binding. :macro:
@briantrice
briantrice / partial-message-cascade.st
Created November 13, 2010 22:34
Before and after
"Before:"
r@(Range traits) hash
[
(((r start hash bitShift: 2)
bitOr: r end hash)
bitShift: 1)
bitOr: r size
].
@briantrice
briantrice / Usage
Created October 31, 2010 01:52
Implementation
slate[4]> #(3 + _) `er applyTo: {4}.
7
define: #Particle &parents: {Mapping} &slots: {#keys -> {}. #values -> {}}.
p@(Particle traits) newSize: capacity
[
p clone `>> [keys: (p keys newSize: capacity). values: (p values newSize: capacity). ]
].
p@(Particle traits) newFrom: keys to: values
[
p clone `>> [keys: (keys as: p keys). values: (values as: p values). ]