Skip to content

Instantly share code, notes, and snippets.

@ebb
ebb / test_zz.84
Last active December 14, 2023 04:10
Big integers
Begin {
(STDIO.print_line >[<"1234" ** <"2000001"])
}
Where
Open Package "z"
{
:Infix <
@ebb
ebb / format.84
Created August 27, 2023 00:37
printf-style string formatting
Let format
Let parse
Define (copy s h i term) If [h = i] term 'copy.{(clip s h i) term}
Define (subst c term) 'subst.{c term}
Let finish 'finish
In
Func s
Let m (length s)
In
Unfold {h i} From {0 0}
@ebb
ebb / cps.84
Created August 7, 2023 16:38
CPS
Define (convert term)
Let gensym
Let r (CHUNK.new_rw 1) In
Func {}
Begin {
Let i (CHUNK.fetch_byte r 0)
(CHUNK.store_byte r 0 [i + 1])
'gen_var.i
}
In
@ebb
ebb / Makefile
Created January 5, 2023 02:59
OO sample for reddit
# Just modify the existing Makefile so the "PROGRAMS = 84" line has "reddit" added to the end as follows:
### Configuration variables
PROGRAMS = 84 reddit
@ebb
ebb / support.s
Created June 15, 2021 01:46
Compiling to x86 - sample code
; Unused primitive identifiers
;
; 00 02 04 07 08
; 12 16 17
; 20 21 23 25 28 29
; 34 36 37
; 44 46 49
; 54 56 57 58 59
; 60 64 65 69
; 70 71 73 76 77 79
; Unused primitive identifiers
;
; 00 02 04 07 08
; 12 16 17
; 20 21 23 25 28 29
; 34 36 37
; 44 46 49
; 54 56 57 58 59
; 60 64 65 69
; 70 71 73 76 77 79
extern P
global heap_bytes
global heap_limit
global heap_top
global _start
global memcpy
global memset
@ebb
ebb / support2.s
Created September 20, 2020 23:14
extern P
global _start
global memcpy
global memset
global strlen
global syscall0
global syscall1
@ebb
ebb / binex.84
Created September 14, 2020 00:41
Begin {
When [OS.argc != 2] {
(die "usage: binex n")
}
Begin Match (Z.read (OS.argv 1)) {
| 'nothing
(die "usage: binex n")
| 'just.n
[n -> binex1 -> STDIO.print_line]
[n -> binex2 -> STDIO.print_line]
@ebb
ebb / line.c
Created January 31, 2020 00:32
//
// Drawing antialiased lines without using floating point numbers
//
// Compile:
//
// $ clang -std=c11 -o line line.c
//
#include <stdio.h>
#include <stdlib.h>