Skip to content

Instantly share code, notes, and snippets.

// lambda trampoline
#include <stdio.h>
void foo(char *s)
{
__asm("foo_label:");
printf("%s\n", s);
}
// lambda trampoline. crashes with gcc -O2 and -O3.
#include <stddef.h>
#include <stdio.h>
void
foo(char *s)
{
__asm("foo_label:");
printf("%s\n", s);
print "You have no mail.\n"
10000.times {
'$ '.display
gets.each do | e |
if (e == "uname\n")
puts "Runix 1.0"
elsif (e == "halt\n")
exit
else
// mutually recursive listener and broadcaster types with
// f-bounded polymorphism
class ListenerType<L extends ListenerType<L, B>, B extends BroadcasterType<L, B>> {
}
class BroadcasterType<L extends ListenerType<L, B>, B extends BroadcasterType<L, B>> {
}
class Listener extends ListenerType<Listener, Broadcaster> {
}
class Broadcaster extends BroadcasterType<Listener, Broadcaster> {
}
#include <stdio.h>
#define CALL(name, ...) \
{ \
int the_args[] = { __VA_ARGS__ }; \
name(sizeof(the_args) / sizeof(int), the_args); \
}
void the_fun(unsigned nargs, int *args)
{
(defclass (term A))
(defclass literal-term ((term number))
((value number))
(:constructor ((value number))))
(defclass is-zero-term ((term boolean))
((subterm (term number)))
(:constructor ((subterm (term number)))))
abstract class Term<T> {
abstract T eval();
}
class IntegerTerm extends Term<Integer> {
Integer value;
IntegerTerm(Integer value) { this.value = value; }
Integer eval() { return value; }
}
@manuel
manuel / edgelisp-content-based-storage.lisp
Created June 12, 2011 18:24
Sample of EdgeLisp's content-based storage
;;; Sample of EdgeLisp's content-based storage system
;;; https://github.com/manuel/edgelisp/blob/master/client/base.lisp
;; Create a blob containing the file's contents.
(defvar test-blob (base-make-blob "Hello content-centric world!"))
#[base-blob Hello content-centric world!]
;; Create a tree with a directory entry named "hello.txt" pointing to the blob's ID (hash).
(defvar test-tree
(base-make-tree (list (base-make-dentry "hello.txt" (base-object-id test-blob)))))
@manuel
manuel / delimc.lisp
Created August 26, 2011 13:49
Delimited control example
(run-cc
($lambda ()
($let ((p (make-prompt)))
(+ 2 ($push-prompt p
($if (with-sub-cont p
($lambda (k)
(+ ($push-sub-cont k #f)
($push-sub-cont k #t))))
3
4))))))
@manuel
manuel / noooooooooooooo.txt
Created December 6, 2011 22:52
noooooooooooooo
Welcome to Racket v5.1.1.
> (define-syntax bar (syntax-rules () ((_) 1)))
> (define (foo) (bar))
> (foo)
1
> (define-syntax bar (syntax-rules () ((_) 55555)))
> (foo)
1 ;; NOOOOOOOOOO!!!