Skip to content

Instantly share code, notes, and snippets.

View vladimir-vg's full-sized avatar
🙂

Vladimir Gordeev vladimir-vg

🙂
View GitHub Profile
;; simple
(define (fac acc n)
(if (= n 1)
acc
(fac (* acc n) (- n 1))))
;; not
(define (fac n)
(if (= n 1)
1
@vladimir-vg
vladimir-vg / gist:857166
Created March 6, 2011 09:32
strange case-statement
x = 16
puts case x.class
when String.class
"string"
when Fixnum.class
"fixnum"
else
"other"
end
@vladimir-vg
vladimir-vg / test.rl
Created March 29, 2011 20:13
related to question in ragel-users mailing-list.
%%{
machine lisp;
integer = '-'? . ('0'|[1-9][0-9]*);
string = '"' . (any - '"') . '"';
list = '(' . (integer|string|list)* . ')';
main := list;
}%%
$ gcc moped.c -Wall -Wextra -ansi
$ ./a.out
@vladimir-vg
vladimir-vg / example.alz
Created April 8, 2011 11:40
Alonzo syntax example
module 'module_name, as: [
Greeter = object, as: [
method 'hello_world, as: [
"Hello world!"
]
method 'hello, as: [ some_word |
"Hello #{some_word}!"
]
module.alonzo.message [|
import [| alonzo.object ]
Message = Object.clone_as [|
slot_rw ['method_name, 'first_arg]
slot_r 'named_args
@named_args = {}
method 'mirror, as: [|
$ cat test1.c
#include <stdio.h>
int main() {
int *a;
printf("addr:%d\n", (int)a);
return 0;
}
$ cat test2.c
@vladimir-vg
vladimir-vg / parse-fail.cpp
Created May 15, 2011 19:01
g++ goes to infinite loop when try to parse this.
template<class T> struct Loop { Loop<T*> operator->(); };
Loop<int> i, j = i->hooray;
1.year + 2.months + 3.weeks # => 1 year, 2 months, and 21 days
2.hours + 30.minutes # => 9000 seconds
config.grid_fs_host = Mongoid.config.master.connection.host