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
| #lang scheme | |
| (letrec ([recur | |
| (lambda (x) | |
| (cond | |
| [(zero? x) (display "Countdown complete.")] | |
| [else (printf "Counting ~s~n" x) | |
| (recur (- x 1))]))]) | |
| (recur 10)) |
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
| #lang scheme | |
| (letrec ([recur1 | |
| (lambda (x) | |
| (cond | |
| [(< x 0) (display "Countdown complete.")] | |
| [else (printf "Counting ~s~n" x) | |
| (recur2 (- x 1))]))] | |
| [recur2 | |
| (lambda (x) |
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
| #lang scheme | |
| ; Brace yourself | |
| (define Z | |
| (lambda (f) | |
| ((lambda (x) (f (lambda (y) ((x x) y)))) (lambda (x) (f (lambda (y) ((x x) y))))))) | |
| ((Z (lambda (f) | |
| (lambda (x) ; Our factorial definition begins here, f is the recursive call |
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
| ;; We define a "struct", which is like a C struct, for the rooms. Note that there | |
| ;; Are default values which can be used if we omit one from construction. | |
| (defstruct my-room | |
| (desc "An empty room.") | |
| ;; The exits will be a list of lists, what lispniks call an "assoc-list" | |
| ;; like so: ( (north room1) (south room2) ) | |
| ;; Think of it as a kind of simple tree. | |
| (exits ())) |
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 Array | |
| def multisplit(wordlist, &block) | |
| result = wordlist.inject([[],[]]) do |memo,word| | |
| bigaccum, smallaccum = memo | |
| if block.call(word) | |
| [bigaccum.push(smallaccum.compact),[]] | |
| else | |
| [bigaccum,smallaccum.push(word)] | |
| end | |
| end |
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> | |
| /******************************************************* | |
| * SAMPLE COMPILATION AND OUTPUT | |
| * | |
| * % gcc -o overflow_example example.c ; ./overflow_example | |
| * I just overflowed, I am now negative! | |
| * Current Value is: -32768 | |
| * Last Value is: 32767I have looped back upon myself to 0! | |
| * |
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
| ; Rule #1, fuck pastebin. | |
| (declare get-rmi lookup-rmi MyMessage) | |
| (defmacro invoke-rmi[hostname port nm iface mthd & args] | |
| `(let [r# (get-rmi ~hostname ~port)] | |
| (let [z# (lookup-rmi r# ~iface ~nm)] | |
| (. z# ~mthd ~@args)))) | |
| ; and now use that macro |
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
| (ns exchat | |
| (:use [clojure.contrib server-socket duck-streams str-utils]) | |
| (:gen-class)) | |
| ;;; This code provides asycnhronous I/O for rooms. | |
| (def rooms (ref {})) | |
| (defn make-get-room! [name] | |
| (dosync | |
| (or (@rooms name) | |
| (let [room (agent (list))] |
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
| CPU SAMPLES BEGIN (total = 211) Sun Dec 27 10:45:50 2009 | |
| rank self accum count trace method | |
| 1 1.42% 1.42% 3 301430 clojure.asm.Type.getInternalName | |
| 2 1.42% 2.84% 3 301464 clojure.lang.RestFn.invoke | |
| 3 1.42% 4.27% 3 301508 clojure.lang.RT.seqFrom | |
| 4 1.42% 5.69% 3 301456 clojure.lang.PersistentVector$TransientVector.editableTail | |
| 5 0.95% 6.64% 2 301495 clojure.lang.PersistentList.cons | |
| 6 0.95% 7.58% 2 301420 clojure.lang.Compiler.analyzeSeq | |
| 7 0.95% 8.53% 2 301485 clojure.lang.PersistentList.first | |
| 8 0.95% 9.48% 2 301476 clojure.lang.LazySeq.more |
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
| CPU SAMPLES BEGIN (total = 205) Sun Dec 27 10:52:27 2009 | |
| rank self accum count trace method | |
| 1 1.46% 1.46% 3 301336 clojure.template__init.load | |
| 2 1.46% 2.93% 3 300339 java.lang.Class.forName0 | |
| 3 0.98% 3.90% 2 301445 clojure.lang.PersistentHashMap.containsKey | |
| 4 0.98% 4.88% 2 301456 clojure.lang.RestFn.invoke | |
| 5 0.98% 5.85% 2 301486 clojure.lang.PersistentVector$TransientVector.editableTail | |
| 6 0.98% 6.83% 2 301487 clojure.lang.PersistentVector$TransientVector.conj | |
| 7 0.98% 7.80% 2 301465 clojure.lang.PersistentVector.chunkedSeq | |
| 8 0.98% 8.78% 2 301489 palindromes$ext_centers__96$fn__101.invoke |