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 | |
(define ((foo #:a? [a? #t] #:b? [b? #t]) x) | |
(when b? | |
(displayln "b!")) | |
(if a? | |
(+ x 1) | |
(+ x 2))) | |
(define fooanb (foo #:b? #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/base | |
(require plot | |
racket/list | |
racket/dict) | |
(module+ test | |
(require rackunit)) | |
(define (string-ticks string-list) | |
(let* ([N (length string-list)] |
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 | |
(provide latex-math-chars) | |
;;; LaTeX math to Unicode symbols translation dictionaries. | |
;;; Adapted from | |
;;; anaconda/lib/python2.7/site-packages/docutils/utils/math/tex2unichar.py | |
;;; itself generated with ``write_tex2unichar.py`` from the data in | |
;;; http://milde.users.sourceforge.net/LUCR/Math/ | |
;;; Includes commands from: wasysym, stmaryrd, mathdots, mathabx, esint, bbold, amsxtra, amsmath, amssymb, standard LaTeX |
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
#!r6rs | |
(import (rnrs (6))) | |
;; Performs a depth-first search without a get-previous-state function, by enumerating | |
;; the paths and restarting at the root for each new path. | |
;; Requires only the memory of the current state and a O(depth-max) memory of other things. | |
;; num-actions: positive-integer? | |
;; Number of children per node. | |
;; get-start-state: none/c -> state? |
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 data/heap) | |
;;; Not the most optimized version. | |
(define N 12) | |
(define (hanoi N) | |
(define visited (make-hash)) | |
(define heap (make-heap (λ(a b) (<= (first a) (first b))))) |
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 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)) |
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 racket/sandbox) | |
;; Make sure you have at least 4×max-memory available | |
;; otherwise your computer might freeze. | |
(define max-memory 1024) | |
(define a-tree #f) | |
;; with-limits should limit the memory use, but it fails in this case. | |
;; See below for an explanation. |
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 | |
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or | |
;;; [MIT license](http://opensource.org/licenses/MIT) at your option. | |
(require quickscript | |
racket/format | |
racket/class) | |
;; Like classify position, but gives the class of the character at the insert position, |
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 | |
(require racket/gui/base | |
racket/class | |
quickscript) | |
;;; The default 'Tabs' menu in DrRacket lists only the first 10 tabs. | |
;;; This script displays all tabs, which is particularly convenient when | |
;;; there are many tabs and not all of them are visible. | |
(define-script all-tabs |
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
#!/usr/bin/racket | |
#lang racket/base | |
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or | |
;;; [MIT license](http://opensource.org/licenses/MIT) at your option. | |
;; When installing a new version of Racket, | |
;; running this script setups all existing packages that had been installed | |
;; in the *user* scope. | |
;; |