Skip to content

Instantly share code, notes, and snippets.

View spdegabrielle's full-sized avatar

Stephen De Gabrielle spdegabrielle

View GitHub Profile
@spdegabrielle
spdegabrielle / draw-partly-rounded-shape.rkt
Created November 29, 2017 18:40 — forked from tonyg/draw-partly-rounded-shape.rkt
Drawing partly-rounded-rectangles using Racket's path support
#lang send-exp racket
(require racket/draw)
(define-syntax-rule (build-path (p) body ...)
(let ((p (new dc-path%)))
body ...
p))
(define (quarter-circle p cx cy quarter radius)
@spdegabrielle
spdegabrielle / gist:e02b748cb6bc4a0d9715d5dc0784fee5
Created December 3, 2017 16:41 — forked from danking/gist:1068185
A very simple example showing how to use Racket's lexing and parsing utilities
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()
module type CELL = sig
type 'a cell
type 'a exp
val return : 'a -> 'a exp
val (>>=) : 'a exp -> ('a -> 'b exp) -> 'b exp
val cell : 'a exp -> 'a cell exp
val get : 'a cell -> 'a exp
http://chronos-st.blogspot.com/2007/12/smalltalk-in-one-page.html
http://www.csci.csusb.edu/dick/samples/smalltalk.syntax.html
Formal EBNF Specification of Smalltalk Syntax
1. Character = ? Any Unicode character ?;
2. WhitespaceCharacter = ? Any space, newline or horizontal tab character ?;
3. DecimalDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
4. Letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M"
| "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
@spdegabrielle
spdegabrielle / standard-cat.rkt
Created July 20, 2019 14:11 — forked from deeglaze/standard-cat.rkt
working out the definition of Racket's to-be standard-cat
#lang racket
(require pict/color)
(provide
(contract-out
[cat-silhouette
(->i ([width positive?] [height positive?])
(#:left-ear-extent [left-ear-extent (>=/c 0)]
#:left-ear-arc [left-ear-arc (real-in 0 (* 2 pi))]
#:left-ear-angle [left-ear-angle (real-in 0 (* 2 pi))]
@spdegabrielle
spdegabrielle / fizzbuzz.rkt
Last active September 26, 2020 18:43 — forked from nilp0inter/fizzbuzz.rkt
The first beautiful implementation of FizzBuzz?
#lang 2d racket
(require 2d/match)
(define (fizz? n)
(zero? (modulo n 5)))
(define (buzz? n)
(zero? (modulo n 3)))
@spdegabrielle
spdegabrielle / world-map.rkt
Created August 20, 2019 03:01 — forked from alex-hhh/world-map.rkt
World Map, standard-fish competition 2019
#lang racket
(require json racket/draw math/base)
(define (lat-lon->map-point coordinates)
(match-define (list lon lat _ ...) coordinates)
(define-values (x y) (values (degrees->radians lon) (asinh (tan (degrees->radians lat)))))
(list (/ (+ 1 (/ x pi)) 2) (/ (- 1 (/ y pi)) 2)))
(define (draw-polygon dc polygons)
(define path
@spdegabrielle
spdegabrielle / standard-lightbulb.rkt
Created September 3, 2019 09:54 — forked from LiberalArtist/default-lightbulb.png
A Racket lightbulb for the Standard Fish Summer Competition 2019
#lang racket/base
;; License: Apache-2.0
(require racket/draw
pict
racket/class
racket/math
racket/list
racket/contract)
@spdegabrielle
spdegabrielle / racket-logo-plot.rkt
Created September 3, 2019 10:31 — forked from Metaxal/racket-logo-plot.rkt
Lambda logo with Racket's plot
#lang racket
(require plot)
(let ([blue '(0 0 164)] [red '(164 0 0)])
(parameterize ([plot-decorations? #f])
(plot3d
(list
(surface3d (λ(x y)(/ x 10)) 0 5 0 1 #:color red #:line-color red)
(surface3d (λ(x y)(- 1 (/ (+ 1 (exp (- 5 x)))))) 0 10 0 1 #:color blue #:line-color blue))
#lang racket/base
(require racket/match racket/list racket/port racket/string
flomat)
;;;
;;; Homogeneous coordinates for 3 dimensions
;;;
; Follow the tutorial
; http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/