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
[email protected] | |
I have questions about some Common Lisp code. First, I'm unfamiliar with defsubst. Is it a standard macro? | |
Yes, defsubst is a standard macro in Common Lisp. It is similar to defun, which is used to define functions, but with a key difference: defsubst is used to define inline functions, also known as "substitute functions" or "substitutions". | |
When a function is defined with defsubst, the compiler is advised to expand the function at compile-time, essentially inlining the function's body wherever it is called. This can lead to performance improvements, as the function call overhead is eliminated. However, it may also increase the size of the compiled code. | |
Keep in mind that using defsubst is just a suggestion to the compiler, and it is not guaranteed to inline the function. The decision is ultimately up to the compiler's optimization settings and heuristics. | |
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
Hi ChatGPT, can you write some code for me in a dialect of Scheme? | |
Of course! I can provide you with an example of code in a dialect of Scheme. Here's a simple program that demonstrates a recursive implementation of the factorial function in Racket, a popular dialect of Scheme. | |
scheme | |
Copy code | |
#lang racket | |
(define (factorial n) | |
(if (= n 0) | |
1 |
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
;; Some macros to make ELisp more like Cant. Just for my own use. | |
(put 'be 'lisp-indent-function 1) | |
(put 'else 'lisp-indent-function 0) | |
;; TODO is there not a better way? | |
(font-lock-add-keywords 'emacs-lisp-mode | |
`((,(regexp-opt '("be" "begin" "else")) . font-lock-keyword-face))) | |
(defmacro hide (&rest body) |
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
(A conversation with ChatGPT. I added some notes below this gist.) | |
---- | |
I'll teach you a Lisp-family language called Cant. Here's an interaction in the REPL. | |
-> (to (I-am name) (out .say "Hi, ~w!\n" name)) | |
-> (I-am 'Alice) | |
Hi, Alice! | |
The interpreter prompted with "->". I typed in a definition of the `I-am` function, and then called it at the next prompt. `"Hi, ~w!\n" is a string literal, while `Alice` is a Lisp symbol, quoted with `'` to distinguish it from a variable. |
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
Learning https://www.ma.imperial.ac.uk/~buzzard/xena/natural_number_game/ | |
Notes on the UI: | |
There's no sandbox that'd let you explore creating new theorems. | |
(I was stuck on one in Multiplication World but thought I'd be able to | |
prove a variation with the expressions commuted, (a+b)*t = a*t + b*t. | |
Hopefully that'd help me get unstuck.) | |
There are 4 panes (names mine): | |
Docs Editor 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
--- semantle.js 2022-02-19 22:16:27.654749238 -0600 | |
+++ semantle_untested.js 2022-02-19 22:50:24.281830204 -0600 | |
@@ -119,7 +119,13 @@ | |
if (oldGuess === guess) { | |
color = '#cc00cc'; | |
} else { | |
- color = '#000000'; | |
+ // XXX untested | |
+ let guessCount = guessed.size; | |
+ if (guessCount - 3 < guessNumber) { // Is this one of the most recent guesses? |
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
Structure and Interpretation of Computer Programs https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book.html | |
https://www.nand2tetris.org/ | |
https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours | |
A Philosophy of Software Design | |
https://www.amazon.com/Philosophy-Software-Design-John-Ousterhout/dp/1732102201/ref=sr_1_1 | |
The Innovator's Dilemma |
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
""" | |
derived from Kragen Sitaker's http://canonical.org/~kragen/sw/dev3/caronte.py | |
""" | |
from __future__ import division, print_function | |
import itertools | |
import grammars | |
from semantics import ast_semantics, ComboSemantics, DictSemantics | |
grammar_text = r""" |
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
""" | |
derived from Kragen Sitaker's http://canonical.org/~kragen/sw/dev3/caronte.py | |
""" | |
from __future__ import division, print_function | |
from parson import Grammar | |
# TODO {'foo'} won't work quite right with FNORD | |
grammar_text = r""" |
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/python3 | |
# -*- coding: utf-8 -*- | |
"""Caronte: uma pequena lua. | |
(from http://canonical.org/~kragen/sw/dev3/caronte.py by Kragen Sitaker, hacked a bit by Darius) | |
This is part of a series of simple exercises I’ve been doing in | |
hacking programming-language prototypes together from scratch in one | |
day. After 4½ hours this successfully generates a fractal and I am | |
going to bed happy. It compiles a tiny infix language into a |