This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define lambda-cache (make-hash-table)) | |
| (define (add-to-cache args) | |
| (let ((fn (car args)) | |
| (a (cadr args))) | |
| (hash-table-set! lambda-cache args (fn a)) | |
| (hash-table-ref lambda-cache args))) | |
| (define (dynamic-call . args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define (compile io-port) | |
| (display "(display \"") | |
| (let loop ((c (read-char io-port)) | |
| (compile-state "normal")) | |
| (if (not (eof-object? c)) | |
| (begin | |
| (loop (read-char io-port) (handle-token c compile-state))) | |
| (if (equal? compile-state "normal") | |
| (begin | |
| (display "\")") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int fib(n) { | |
| if ((n == 0)||(n == 1)) { | |
| return n; | |
| } else { | |
| return fib(n-1) + fib(n-2); | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/mzscheme | |
| #lang scheme | |
| (define (fib n) | |
| (if (or (= 0 n) (= 1 n)) n | |
| (+ (fib (- n 1)) (fib (- n 2))))) | |
| (let runfib ((i 0)) | |
| (unless (= i 36) | |
| (display (string-append "n = " (number->string i) " => " (number->string (fib i)) "\n")) | |
| (runfib (+ i 1)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun fib (n) | |
| (if(or (= 0 n) (= 1 n)) n | |
| (+ (fib (- n 1)) (fib (- n 2))))) | |
| (defun start () | |
| (loop for x from 0 to 35 collect | |
| (format t "n = ~d => ~d~%" x (fib x)))) | |
| (start) | |
| (quit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class fib { | |
| public static int fib(int n) { | |
| if (n <= 1) {return n;} | |
| return fib(n-1) + fib(n-2); | |
| } | |
| public static void main(String[] args) { | |
| for (int i = 0; i < 36; i++) | |
| System.out.println("n = " + i + " => " + fib(i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fib(n) | |
| if n == 0 || n == 1 | |
| n | |
| else | |
| fib(n - 1) + fib(n - 2) | |
| end | |
| end | |
| if $0 == __FILE__ | |
| 36.times do |i| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/ruby | |
| require "open-uri" | |
| id=ARGV[0] | |
| if !id then | |
| puts "No id given" | |
| else | |
| begin | |
| puts open("http://gist.github.com/#{id}.txt").read | |
| rescue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| package GopherScript; | |
| sub new | |
| { | |
| my $class = shift; | |
| my $self = { | |
| hostname => shift, | |
| port => shift, | |
| mode => "dir", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GopherClient | |
| def parseurl(url) | |
| opts=url.sub('gopher://','').split('/') # split the url by slashes | |
| host=opts.shift # the first element will be our host | |
| type=opts.shift # type is second | |
| if !@types.has_key?(type) then # check to see if a type was provided | |
| opts.unshift(type) # if not, then its part of the path, put it back | |
| puts "No type given, assuming 1" # tell them the error of their ways | |
| type="1" # and assume its a directory | |
| end |