Skip to content

Instantly share code, notes, and snippets.

View LdBeth's full-sized avatar

LdBeth

View GitHub Profile
#|
| Event extract script
|
| Copyright (c) 2018, LdBeth Wang
| All rights reserved.
|
| Redistribution and use in source and binary forms, with or without
| modification, are permitted provided that the following conditions are
| met:
|
@LdBeth
LdBeth / ca.dyalog
Created February 2, 2020 09:59
APL plot code for A New Kind of Science
acc ← {⍺←1 ⋄ ((⊢⍪(⍺⍺∘,¯1↑⊢))⍣⍺)⍵}
cell ← {((⍺⍺ ⍵⍵⊢)⌺3)⍵}
code ← {⎕IO←0 ⋄ (+/⍵)⌷⌽(7⍴3)⊤⍺}
expnd ← {(,⍉↑⍺)/,¯1 0 1(+⍤0 1)⍵}
gmob ← {⍵ snap⍨(⊂L),↓⍉↑(⍺⍺ ⍵⍵ ⍵⌷⍨∘⊂¯1 0 1∘+)¨L←⍸1<⍵}
gr ← {(A rule P)(B patn P)⊣A B←⍺⊣P←2|⍵}
initi ← {⍺←1 ⋄ ,[⎕IO-0.5]A,⍺,A←⍵⍴0}
mcomp ← {((⌽⍣(B rule P))0 0 2)+(⊃A B←⍺)patn⊢P←⍵-0 2 0}
mobile ← {((⍺⍺ ⍵⍵ ⍵⌷⍨⊂P)@P)⍵⊣P←¯1 0 1+⍸1<⍵}
msimp ← {((⌽⍣A)0 0 2)+(B@2)P⊣A B←⍺ rule¨⊂P←⍵-0 2 0}
@LdBeth
LdBeth / algorithm-t.lisp
Created April 12, 2020 01:47
Algorithm T
(defun factorial(x)
(reduce '* (loop for a from x downto 1 collect a)))
(defun algorithm-t (n &aux (num (factorial n)))
(let ((table (make-array num :element-type `(integer 1 ,n) :initial-element 0))
(m 2)
j k d)
(setf d (floor num 2)
(aref table d) 1)
(loop until (= m n)
@LdBeth
LdBeth / mukaren.icl
Last active May 14, 2020 05:47
MuKaren in Clean
module mukaren
import StdEnv,StdMaybe,StdClass
:: Tree = Node Tree Tree | Var Int | Val Int
:: State :== ([(Int,Tree)], Int)
:: Mu :== (State -> [State])
instance == Tree
where
&anchor = 1
char = len(1) . ch
white = span(' ')
word = break(' ') white
count = table(100)
loop line = input :f(stat)
lc = lc + 1
copy = line ' '
@LdBeth
LdBeth / aplbot.lisp
Last active February 18, 2022 05:46
discord bot that evals april
#|
BSD 2-Clause License
Copyright (c) 2022, LdBeth
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
@LdBeth
LdBeth / horoscope.lisp
Last active November 17, 2022 21:19
Mastodon horoscope bot
(eval-when (:compile-toplevel :load-toplevel :execute)
(defpackage #:horoscope))
(in-package #:cl-user)
(defparameter horoscope::paragraph
'(("*sentence." "*sentence2." "*sentence." "*sentence2."
"You'll" "*when" "be" "*state." "*luckynum.")
("*sentence." "*sentence2." "*sentence2." "You'll" "*when" "be" "*state.")
("*sentence2." "*sentence." "*sentence." "*sentence2."
"You'll" "*when" "be" "*state.")))
@LdBeth
LdBeth / mkpdf.icl
Created July 5, 2022 00:35
Create pdf from jbig2 files
// clm -IL Platform -IL ArgEnv -IL Directory -IL StdLib -b -nr -nt mkpdf -o pdf
// rewrite of https://github.com/agl/jbig2enc/blob/master/pdf.py
module mkpdf
import StdEnv, ArgEnv, StdMaybe, StdArrayExtensions, Directory, Data.Func
Start w
| argc == 1
# (p, w) = getCurrentDirectory w
((ec, files), w) = getDirectoryContents p w
@LdBeth
LdBeth / custom.xsl
Created October 25, 2022 17:20
xslTNG customization used to build my website.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:v="http://docbook.org/ns/docbook/variables"
xmlns:m="http://docbook.org/ns/docbook/modes"
xmlns:f="http://docbook.org/ns/docbook/functions"
xmlns:fp="http://docbook.org/ns/docbook/functions/private"
xmlns:t="http://docbook.org/ns/docbook/templates"
fmod PATH is
protecting STRING .
protecting BOOL .
sorts Path Node .
subsort String < Node .
op _-_ : Node Node -> Path [ctor comm] .
op small : Node -> Bool .
var s : Node .
eq small(s) = ascii(substr(s, 0, 1)) > 90 .