├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── README.md ├── TODO.txt ├── barrel.sh ├── barrel ├── barrel.rkt ├── core.rkt ├── expander.rkt ├── info.rkt ├── main.rkt ├── parser-test.rkt ├── parser.rkt ├── reader.rkt ├── scribblings │ └── barrel.scrbl ├── tokenizer.rkt └── util.rkt ├── examples ├── fibonacci.brl ├── helloworld.brl ├── map.brl └── quine.brl └── tests ├── if.brl └── random.brl /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The "build" and "bundle" directories are used when creating installers 2 | # via the `server', `client', and/or `farm' makefile targets. 3 | /build/ 4 | /bundle/ 5 | 6 | # It's common to configure the PLTADDONDIR to be here. 7 | /add-on/ 8 | 9 | # This is where to put packages installed with `--clone` 10 | /extra-pkgs/ 11 | 12 | # Everything below makes sense on any package repository, so it's 13 | # stuff that should be put into each such repository. The same holds 14 | # for ".mailmap" (which some people can decide if they want to thin it 15 | # out or not include it) and for ".gitattributes" (which is probably 16 | # irrelevant except maybe for the core repo). 17 | 18 | compiled/ 19 | 20 | # common backups, autosaves, lock files, OS meta-files 21 | *~ 22 | \#* 23 | .#* 24 | .DS_Store 25 | *.bak 26 | TAGS 27 | *.swn 28 | *.swo 29 | *.swp 30 | .gdb_history 31 | /.vscode/ 32 | 33 | # generated by patch 34 | *.orig 35 | *.rej 36 | 37 | # coredumps 38 | *.core 39 | 40 | # generated by scribble 41 | barrel/scribblings/*.js 42 | barrel/scribblings/*.css 43 | !barrel/scribblings/mb.css 44 | barrel/scribblings/*.html 45 | barrel/scribblings/barrel/* 46 | doc/* 47 | barrel/doc/* -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022 crab 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BARREL IS DISCONTINUED FOR NOW 2 | 3 | # barrel 4 | 5 | an esoteric golfing stack language heavily inspired by Joy, K and CJam. 6 | 7 | # examples 8 | 9 | hello world: 10 | ```racket 11 | "hello world" 12 | ``` 13 | 14 | quine: 15 | ``` 16 | 1 17 | ``` 18 | 19 | fibonacci (does not work yet): 20 | ``` 21 | [1≤]1-:1-]ν 22 | ``` 23 | 24 | # install 25 | 26 | install racket, and then the barrel packgae. If the racket 8.4 folder is in your path, then you have the barrel executables `barrel` and `brl`. 27 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | FEATURES: 2 | - for loops 3 | - list operations 4 | - Fried notation for quotations 5 | - primrec, binrec, genrec, treerec, linrec, monoidal versions and a bunch of joy combinators 6 | - Copy CJam functions http://foldr.moe/cjam.pdf, and Joy functions https://hypercubed.github.io/joy/html/html-manual.html 7 | - Ending }, ] and " are optional 8 | - Local bindings which pop values off the stack and assign them to names and a generalized peek, which doesnt pop. 9 | - Custom Encoding for unicode 10 | - MATRICES 11 | - DICTIONARIES (`[[3"fizz"][5"buzz"][7"buzz"]]`) 12 | - ^^ have an operator that takes a number and tuplefies that many elements. 13 | so [3"fizz"5"buzz"7"buzz"3(OP)] = [[3"fizz"][5"buzz"][7"buzz"]]. Even better, maybe make it wrap in quote by default. 14 | - Have the functions `first` and `second` that get the first and second elements of a quotation. 15 | - More IO operators 16 | - Boolean Operators (AND, OR, NOT, ETC) 17 | - BETTER ERROR MESSAGES 18 | - implicit inputs like in osabie 19 | 20 | FUTURE: 21 | - function that takes in a number and puts the top n elements in a quotation 22 | - conversion operators 23 | - Use 「 」 for quote or function brackets 24 | - Version of map for strings 25 | 26 | BUGS: 27 | - FIX IF EXPRESSIONS URGNET 28 | 29 | CODE STYLE: -------------------------------------------------------------------------------- /barrel.sh: -------------------------------------------------------------------------------- 1 | name="$(mktemp)" 2 | echo "#lang barrel" >> "$name" 3 | cat $@ >> "$name" 4 | cat - | racket "$name" -------------------------------------------------------------------------------- /barrel/barrel.rkt: -------------------------------------------------------------------------------- 1 | #lang br/quicklang 2 | (require racket/cmdline 3 | barrel/reader) 4 | (command-line 5 | #:args (filename) 6 | ;; parse file 7 | (define module-syntax 8 | (call-with-input-file* filename 9 | (lambda (in) 10 | (read-syntax filename in)))) 11 | ;; eval module form in a namespace with racket/base 12 | (define ns (make-base-namespace)) 13 | (eval module-syntax ns) 14 | ;; require the module in the namespace to run it 15 | (eval `(require ',(second (syntax->datum module-syntax))) ns)) -------------------------------------------------------------------------------- /barrel/core.rkt: -------------------------------------------------------------------------------- 1 | #lang br/quicklang 2 | (require brag/support "util.rkt") 3 | 4 | (define ls (list 1 2 3 4 5) 5 | ) 6 | 7 | ;; UNCOMMENT LATER 8 | #;(provide (all-defined-out)) 9 | 10 | ;; TODO: ERROR HANDLING IN FUNCTIONS 11 | 12 | ;; Evaluation 13 | 14 | (define (print-stack-nice stack) 15 | (for-each (lambda (a) (if (quotation? a) (print-quote #t a) (displayln a))) (filter (or (negate void?) (negate procedure?)) stack))) 16 | (provide print-stack-nice) 17 | 18 | ;; quotation definition 19 | 20 | (define-struct quotation (words)) 21 | (provide make-quotation quotation? quotation-words) 22 | 23 | ;; helper function for applying words and functions 24 | 25 | (define (apply-stack stack words) 26 | (foldl (lambda (f prev) (f prev)) stack words)) 27 | (provide apply-stack) 28 | 29 | (define (apply-word stack words) 30 | (apply-stack stack (quotation-words words))) 31 | (provide apply-word) 32 | 33 | (define (apply-def code stack) 34 | (apply-stack stack (code))) 35 | (provide apply-def) 36 | 37 | (define (bin-op op stack) 38 | (cons (op (second stack) (first stack)) (drop stack 2))) 39 | (provide bin-op) 40 | 41 | (define (bool-bin-op op stack) 42 | (cons (bool->number (op (second stack) (first stack))) (drop stack 2))) 43 | 44 | (define (f-at-top f stack) 45 | (cons (f (first stack)) (rest stack))) 46 | 47 | (define-unhygienic-macro (mk-temp-stack F Q) 48 | #'(define temp-stack (map (lambda (F) (F '())) (quotation-words Q)))) 49 | 50 | ;; IO 51 | 52 | (define (print-quote ln? in-quote) 53 | (define stringed 54 | (string-append 55 | "[" 56 | (string-join (map (lambda (f) 57 | (cond 58 | [(equal? (object-name f) 'curried:push) 59 | (~a (list-ref (f empty) 0))] 60 | [(equal? f "_") f] 61 | [else (func-to-str f)])) 62 | (quotation-words in-quote)) 63 | " ") 64 | "]")) 65 | (if ln? (displayln stringed) (display stringed))) 66 | 67 | (define (brl-print stack) 68 | (if (quotation? (first stack)) 69 | (print-quote #f (first stack)) 70 | (display (first stack))) 71 | (rest stack)) 72 | (provide brl-print) 73 | 74 | (define (brl-println stack) 75 | (if (quotation? (first stack)) 76 | (print-quote #t (first stack)) 77 | (displayln (first stack))) 78 | (rest stack)) 79 | (provide brl-println) 80 | 81 | (define (read stack) 82 | (define input (read-line)) 83 | (cons input stack)) 84 | (provide read) 85 | 86 | (define (print-stack stack) 87 | (displayln (string-append (format "{~a} " (length stack)) 88 | (trim-ends "(" (~a (reverse stack)) ")"))) 89 | stack) 90 | (provide print-stack) 91 | 92 | ;; Stack 93 | 94 | (define (push atom stack) 95 | (cons atom stack)) 96 | (provide push) 97 | 98 | (define (pop stack) 99 | (rest stack)) 100 | (provide pop) 101 | 102 | (define (dup stack) 103 | (cons (first stack) stack)) 104 | (provide dup) 105 | 106 | (define (copy stack) 107 | (cons (list-ref stack (add1 (first stack))) (rest stack))) 108 | (provide copy) 109 | 110 | (define (swap stack) 111 | (define x (first stack)) 112 | (define y (second stack)) 113 | (cons y (cons x (drop stack 2)))) 114 | (provide swap) 115 | 116 | (define (rotate stack) 117 | (define x (first stack)) 118 | (define y (second stack)) 119 | (define z (third stack)) 120 | (cons y (cons z (cons x (drop stack 3))))) 121 | (provide rotate) 122 | 123 | (define (clear stack) 124 | empty) 125 | (provide clear) 126 | 127 | (define (move stack) 128 | (define i (first stack)) 129 | (cons (list-ref stack (add1 i)) (append (take (rest stack) i) (drop (rest stack) (add1 i))))) 130 | (provide move) 131 | 132 | ;; Combinators 133 | 134 | (define (eval stack) 135 | (apply-stack (rest stack) (first stack))) 136 | (provide eval) 137 | 138 | (define (cat stack) 139 | (define q1 (first stack)) 140 | (define q2 (second stack)) 141 | (cons (make-quotation (append (quotation-words q2) (quotation-words q1))) 142 | (drop stack 2))) 143 | (provide cat) 144 | 145 | (define (dip stack) 146 | (define new-stack (cons (second stack) (cons (first stack) (drop stack 2)))) 147 | (eval new-stack)) 148 | (provide dip) 149 | 150 | ;; FIX ITITT THIS SO MUCH ITS SOO ANNOYING AFKDJHEKJFAHEFKAJHFEKJ 151 | (define (brl-if stack) 152 | (if (quotation? (second stack)) 153 | (if (not (= (third stack) 0)) 154 | (eval (remove+ (sub1 (length stack)) (remove+ (- (length stack) 3) stack))) ;; THIS LINE, I JUST WANT IT TO DO '(1 2 3 4 5) -> '(1 2 4) 155 | (eval (remove+ (- (length stack) 3) (remove+ (- (length stack) 3) stack)))) 156 | (if (not (= (second stack) 0)) 157 | (eval (remove+ (- (length stack) 1) stack)) 158 | stack))) 159 | (provide brl-if) 160 | 161 | ;; Lists 162 | 163 | (define (brl-map stack) 164 | (define f (first stack)) 165 | (define ls (second stack)) 166 | (mk-temp-stack f ls) 167 | (define applied 168 | (map (lambda (l) ((curry push) l)) 169 | (flatten (map (lambda (a) (apply-word a f)) temp-stack)))) 170 | (cons (make-quotation applied) (drop stack 2))) 171 | (provide brl-map) 172 | 173 | ;; Math 174 | 175 | (define (plus stack) 176 | (define a (first stack)) 177 | (define b (second stack)) 178 | (define rest (drop stack 2)) 179 | (cond 180 | [(and (number? a) (number? b)) (cons (+ b a) rest)] 181 | [(and (string? a) (string? b)) (cons (string-append b a) rest)] 182 | [else 183 | (displayln "error: type mismatch") 184 | (error 'type-mismatch)])) 185 | (provide plus) 186 | 187 | (define (mult stack) 188 | (bin-op * stack)) 189 | (provide mult) 190 | 191 | (define (sub stack) 192 | (bin-op - stack)) 193 | (provide sub) 194 | 195 | (define (div stack) 196 | (bin-op / stack)) 197 | (provide div) 198 | 199 | (define (exp stack) 200 | (bin-op expt stack)) 201 | (provide exp) 202 | 203 | (define (rem stack) 204 | (bin-op remainder stack)) 205 | (provide rem) 206 | 207 | (define (gcd stack) 208 | (bin-op gcd stack)) 209 | (provide gcd) 210 | 211 | (define (lcm stack) 212 | (bin-op lcm stack)) 213 | (provide lcm) 214 | 215 | ;; Comparison 216 | 217 | (define (lt stack) 218 | (bool-bin-op < stack)) 219 | (provide lt) 220 | 221 | (define (gt stack) 222 | (bool-bin-op > stack)) 223 | (provide gt) 224 | 225 | (define (leq stack) 226 | (bool-bin-op <= stack)) 227 | (provide leq) 228 | 229 | (define (geq stack) 230 | (bool-bin-op >= stack)) 231 | (provide geq) 232 | 233 | (define (eq stack) 234 | (bool-bin-op equal? stack)) 235 | (provide eq) 236 | 237 | (define (neq stack) 238 | (bool-bin-op (negate equal?) stack)) 239 | (provide neq) 240 | 241 | ;; Misc 242 | (define (inf stack) (inf stack)) 243 | (provide inf) -------------------------------------------------------------------------------- /barrel/expander.rkt: -------------------------------------------------------------------------------- 1 | #lang br/quicklang 2 | (require racket/dict 3 | racket/block) 4 | (require "core.rkt" 5 | "util.rkt") 6 | (provide (all-from-out "core.rkt")) 7 | 8 | (provide definitions) 9 | (define definitions (box empty)) 10 | 11 | (define count (box 0)) 12 | 13 | (define-macro (barrel-module-begin PARSE-TREE) #'(#%module-begin PARSE-TREE)) 14 | (provide (rename-out [barrel-module-begin #%module-begin])) 15 | (provide #%top-interaction) 16 | 17 | (define-macro (words WORDS ...) 18 | #'(block (define stack empty) 19 | (define words (list WORDS ...)) 20 | (filter void? words) 21 | (define code (filter (negate void?) words)) 22 | (void (print-stack-nice (apply-stack stack code))))) 23 | (provide words) 24 | 25 | (define-macro (word "{" WORDS ... "}") 26 | #'(block (define code (list WORDS ...)) 27 | (if (> (unbox count) 52) 28 | (raise "reached max definition limit") 29 | (set-box! definitions 30 | (append (unbox definitions) 31 | (list code)))) 32 | (set-box! count (+ (unbox count) 1)))) 33 | (provide word) 34 | 35 | (define-macro (quote~ "[" WORDS ... "]") 36 | #'(block 37 | ;; TODO: Get the STACKK 38 | (define words (list WORDS ...)) 39 | ((curry push) (if (member "_" words) (make-quotation (fried-quote words STACKK)) (make-quotation (list WORDS ...)))))) 40 | (provide quote~) 41 | 42 | (define-macro (fried-quote WORDS STACK) 43 | #'(1)) 44 | 45 | (define-macro (const CONST) #'((curry push) CONST)) 46 | (provide const) 47 | 48 | (define-macro (id ID) 49 | #'(match ID 50 | ;; Stack 51 | ["$" pop] 52 | [":" dup] 53 | ["~" swap] 54 | ["@" copy] 55 | ["#" rotate] 56 | ["!" clear] 57 | ["&" move] 58 | ;; Comparison 59 | ["<" lt] 60 | [">" gt] 61 | ["≤" leq] 62 | ["≥" geq] 63 | ["=" eq] 64 | ["≠" neq] 65 | ;; Combinators 66 | ["η" eval] 67 | ["χ" cat] 68 | ["Δ" dip] 69 | ["?" brl-if] 70 | ;; IO 71 | ["." brl-print] 72 | ["·" brl-println] 73 | ["§" print-stack] 74 | ["," read] 75 | ;; Math 76 | ["+" plus] 77 | ["*" mult] 78 | ["-" sub] 79 | ["/" div] 80 | ["^" exp] 81 | ["%" rem] 82 | ["`" gcd] 83 | ["&" lcm] 84 | ;; List 85 | ["↦" brl-map] 86 | ;; MISC 87 | ["λ" inf] 88 | [ID 89 | ((curry apply-def) 90 | (lambda () (block (define decoded (b52-decode ID)) 91 | (with-handlers ([exn:fail? 92 | (λ (e) (raise (format "word not availible: ~a" 93 | ID)))]) 94 | (list-ref (unbox definitions) (- decoded 1))))))])) 95 | (provide id) -------------------------------------------------------------------------------- /barrel/info.rkt: -------------------------------------------------------------------------------- 1 | #lang info 2 | 3 | (define collection "barrel") 4 | 5 | (define deps 6 | '("base" 7 | "beautiful-racket" 8 | "brag-lib" 9 | "threading-lib" 10 | "br-parser-tools" 11 | "control")) 12 | 13 | (define module-suffixes '(#".brl")) 14 | 15 | (define scribblings '(("scribblings/barrel.scrbl" (multi-page)))) 16 | 17 | (define racket-launcher-names '("barrel" "brl")) 18 | 19 | (define racket-launcher-libraries '("barrel.rkt" "barrel.rkt"))(define build-deps '("racket-doc" 20 | "scribble-lib")) 21 | -------------------------------------------------------------------------------- /barrel/main.rkt: -------------------------------------------------------------------------------- 1 | #lang br/quicklang 2 | 3 | (module reader br 4 | (require "reader.rkt") 5 | (provide read-syntax)) -------------------------------------------------------------------------------- /barrel/parser-test.rkt: -------------------------------------------------------------------------------- 1 | #lang br/quicklang 2 | (require "parser.rkt" "tokenizer.rkt") 3 | 4 | (parse-to-datum "{:*}s;7s.") -------------------------------------------------------------------------------- /barrel/parser.rkt: -------------------------------------------------------------------------------- 1 | #lang brag 2 | words : (word | const | id | quote~)* 3 | quote~ : "[" (const | id | "_")* "]" 4 | word : "{" (const | id)* "}" 5 | const : CONST 6 | id : ID -------------------------------------------------------------------------------- /barrel/reader.rkt: -------------------------------------------------------------------------------- 1 | #lang br/quicklang 2 | (require "parser.rkt" "tokenizer.rkt") 3 | (require racket/contract) 4 | 5 | (define (read-syntax path port) 6 | (define parse-tree (parse path (make-tokenizer port))) 7 | (define module-datum `(module barrel-module barrel/expander 8 | ,parse-tree)) 9 | (datum->syntax #f module-datum)) 10 | (provide (contract-out 11 | [read-syntax (any/c input-port? . -> . syntax?)])) -------------------------------------------------------------------------------- /barrel/scribblings/barrel.scrbl: -------------------------------------------------------------------------------- 1 | #lang scribble/manual 2 | 3 | @title{barrel: A stack language meant for lists} 4 | 5 | @defmodulelang[barrel] 6 | 7 | This is a stack language that uses reverse polish notation. 8 | It is written in @racketmodname[br/quicklang], a slightly modified version of racket. I plan to translate to @racketmodname[racket/base] in the future. 9 | 10 | The goal is to think in a new way with lists, with a forth-like stack language. 11 | 12 | Language is still WIP. There isn't even list support yet. For all existing features, read below. 13 | 14 | Let's start with the classic "Hello, World!": 15 | 16 | @codeblock{ 17 | #lang barrel 18 | 19 | main :: "hello world" . 20 | } 21 | 22 | This results in: 23 | 24 | @verbatim{ 25 | hello world 26 | } 27 | 28 | @section{operators} 29 | 30 | Here are all the current operators in barrel: 31 | 32 | @tabular[#:sep @hspace[3] 33 | (list (list @tt["$"] @italic["pops the first item off the stack"]) 34 | (list @tt[":"] @italic["duplicates the first item on the stack"]) 35 | (list @tt["+"] @italic["sums the top two items on the stack"]) 36 | (list @tt["*"] @italic["subtracts the top two items on the stack"]) 37 | (list @tt["-"] @italic["multiples the top two items on the stack"]) 38 | (list @tt["/"] @italic["divides the top two items on the stack"]) 39 | (list @tt["!"] @italic["negates the first item"]) 40 | (list @tt["."] @italic["prints the first item without a newline and pops it"]) 41 | (list @tt[".\\"] @italic["prints the first item with a newline and pops it"]) 42 | (list @tt["~"] @italic["swaps the top two items on the stack"]) 43 | (list @tt[":@"] @italic["copies an item from a given index to the top of the stack"]) 44 | (list @tt["+s"] @italic["concats the top two items on the stack (meant for strings)"]) 45 | (list @tt["<>"] @italic["reverses the top n elements on the stack"]) 46 | (list @tt["λ"] @bold["undocumented"]))] -------------------------------------------------------------------------------- /barrel/tokenizer.rkt: -------------------------------------------------------------------------------- 1 | #lang br/quicklang 2 | (require brag/support 3 | racket/contract) 4 | 5 | (define (make-tokenizer port) 6 | (define (next-token) 7 | (define brl-lexer 8 | (lexer [(union (char-set "{}[]") "_") lexeme] 9 | [(union (concatenation 10 | (union "-" "") 11 | (concatenation 12 | (:+ numeric) 13 | (union (concatenation "." (:+ numeric)) "")))) 14 | (token 'CONST (string->number lexeme))] 15 | [(from/to "\"" "\"") (token 'CONST (string-trim lexeme "\""))] 16 | [(union symbolic punctuation alphabetic) (token 'ID lexeme)] 17 | [any-char (next-token)])) 18 | (brl-lexer port)) 19 | next-token) 20 | (provide (contract-out [make-tokenizer (input-port? . -> . procedure?)])) -------------------------------------------------------------------------------- /barrel/util.rkt: -------------------------------------------------------------------------------- 1 | #lang br/quicklang 2 | (require racket/contract) 3 | 4 | (define (b52-decode str) 5 | (for/fold ([n 0]) 6 | ([c str]) 7 | (+ (* n 52) (* 58 (if (char<=? c #\Z) 1 0)) (- (char->integer c) (char->integer #\a)) 1))) 8 | (provide (contract-out 9 | [b52-decode (string? . -> . integer?)])) 10 | 11 | (define (lfy e) 12 | (lambda () e)) 13 | (provide lfy) 14 | 15 | (define-macro (func-to-str F) 16 | #'(match (object-name F) 17 | ;; Stack 18 | ['pop "$"] 19 | ['dup ":"] 20 | ['swap "~"] 21 | ['copy "@"] 22 | ['rotate "#"] 23 | [clear "!"] 24 | [move "&"] 25 | ;; Combinators 26 | ['eval "η"] 27 | ['cat "χ"]` 28 | ['dip "Δ"] 29 | ['brl-if "?"] 30 | ;; IO 31 | ['print "."] 32 | ['println "·"] 33 | ['print-stack "§"] 34 | ['read ","] 35 | ;; Math 36 | ['plus "+"] 37 | ['mult "*"] 38 | ['div "/"] 39 | ['exp "^"] 40 | ['rem "%"] 41 | ['gcd "`"] 42 | ['lcm "&"] 43 | ;; List 44 | ['map "↦"] 45 | ;; Comparison 46 | [lt "<"] 47 | [gt ">"] 48 | [leq "≤"] 49 | [geq "≥"] 50 | [eq "="] 51 | [neq "≠"] 52 | 53 | [else (error 'unknown-id)])) 54 | (provide func-to-str) 55 | 56 | (define (bool->number b) 57 | (if b 1 0)) 58 | (provide bool->number) 59 | 60 | (define (remove+ n lst) 61 | (let-values (((front back) (split-at lst n))) 62 | (append (take front (sub1 (length lst))) back))) 63 | (provide remove+) -------------------------------------------------------------------------------- /examples/fibonacci.brl: -------------------------------------------------------------------------------- 1 | [1≤]1-:1-]ν -------------------------------------------------------------------------------- /examples/helloworld.brl: -------------------------------------------------------------------------------- 1 | "hi world" -------------------------------------------------------------------------------- /examples/map.brl: -------------------------------------------------------------------------------- 1 | [1 2 3 4 5][1+]↦· 2 | {:*} 3 | [1 2 3 4 5][a]↦· 4 | [2 13 34 15 3 7][2*]↦· -------------------------------------------------------------------------------- /examples/quine.brl: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /tests/if.brl: -------------------------------------------------------------------------------- 1 | 2 1- 2≠["will print"·]? 2 | 5 3- 3=["wont print".]? 3 | 0 1≠["this is true"·]["this is false"·]? 4 | 3 5<["5 is greater than 3"·]["5 is less than or equal to 3"·]? -------------------------------------------------------------------------------- /tests/random.brl: -------------------------------------------------------------------------------- 1 | {1.a}a --------------------------------------------------------------------------------