This file contains 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 racket | |
(require net/url net/uri-codec net/base64 json) | |
(define f #f) | |
(command-line #:args (file) | |
(set! f file)) | |
(define file-val (file->string f)) |
This file contains 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 racket | |
(module m racket | |
(define-for-syntax x 1) | |
(provide (for-syntax x))) | |
(require 'm) | |
(define-syntax (mac stx) (datum->syntax #'here x)) |
This file contains 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 racket | |
(require ffi/unsafe srfi/67) | |
(define-fun-syntax _unptr | |
(syntax-rules () [(_ t) (type: _pointer pre: (x => (ptr-ref x t)))])) | |
(define qsort | |
(get-ffi-obj 'qsort #f | |
(_fun (l : (_list io _int len)) | |
(len : _int = (length l)) |
This file contains 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
(defn analysis->map | |
"Convert Java Object expr into nested maps" | |
; result type: | |
; (rec X (U {:op :def | |
; :env {:source Object | |
; :line Object} | |
; :var Var} | |
; {:op :if | |
; :env {:source Object | |
; :line Object} |
This file contains 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 typed/racket | |
;; Adapted from http://stackoverflow.com/questions/10384875/why-is-clojure-much-faster-than-mit-scheme-for-equivalent-functions | |
(: sieve : Positive-Index -> (Listof Integer)) | |
(define (sieve n) | |
(let ((#{root : Index} (assert (round (inexact->exact (sqrt n))) index?)) | |
(#{a : (Vectorof Boolean)} (make-vector n #f))) | |
(: cross-out : Integer Fixnum Fixnum -> 0) | |
(define (cross-out t to dt) |
This file contains 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
digraph G { | |
KRC -> Miranda; | |
ML -> Miranda; | |
KRC -> SASL; | |
SASL -> Miranda; | |
Miranda -> Haskell; | |
Hope -> Haskell; | |
Hope -> ML; | |
Clean -> Haskell; | |
FP -> Haskell; |
This file contains 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
;(defn isa? | |
; "Returns true if (= child parent), or child is directly or indirectly derived from | |
; parent, either via a Java type inheritance relationship or a | |
; relationship established via derive. h must be a hierarchy obtained | |
; from make-hierarchy, if not supplied defaults to the global | |
; hierarchy" | |
; {:added "1.0"} | |
; ([child parent] (isa? global-hierarchy child parent)) | |
; ([h child parent] | |
; (or (= child parent) |
This file contains 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 racket/base | |
;; By http://www.reddit.com/user/p4bl0 at http://paste.fulltxt.net/FZ4-HeULc | |
;; `racket -il readline -t http-client.rkt` | |
;; then you can use (M "/path/...") where M can be get, post, put, delete. | |
;; When authenticated, you can logout using (logout). | |
;; The host and port can be changed using set!. | |
(require racket/tcp |
This file contains 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
import random | |
import sys | |
def main(): | |
if len(sys.argv) != 2: | |
print >> sys.stderr, "Usage: %s <elem_count>" % sys.argv[0] | |
exit(-1) | |
count = int(sys.argv[1]) | |
random.seed() |
This file contains 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 typed/racket | |
(define d (read)) | |
(match d | |
[(? number? d) (+ 5 d)] | |
[(? string? d) (string-append "hello " d)] | |
[_ (printf "unknown: ~a\n" d)]) |