2.9 KiB
Scheme
Scheme is a classic programming language in the Lisp family. It emphasizes functional programming and domain-specific languages but adapts to other styles.
In LiveCodes, Scheme code runs in the browser using BiwaScheme, a Scheme interpreter written in JavaScript.
:::info Note
Lisp language family supported in LiveCodes includes Common Lisp, Scheme, ClojureScript and Fennel.
:::
Usage
LiveCodes runs Scheme code in the browser. BiwaScheme implements most of the features of R7RS small, including first-class continuation and tail call optimization.
Example:
import LiveCodes from '../../src/components/LiveCodes.tsx';
export const basicSchemeDemo = { activeEditor: 'script', markup: { language: 'html', content: `
`, }, style: { language: 'css', content: `.container, .container button { text-align: center; font: 1em sans-serif; } .logo { width: 150px; } `, }, script: { language: 'scheme', content: `(let ((title "Scheme")) (set-content! "#title" title))(let ((counter 0)) (add-handler! "#counter-button" "click" (lambda (ev) (set! counter (+ counter 1)) (set-content! "#counter" (number->string counter)))))
; check console (let ((time-now (date-hour (current-date)))) (console-log (cond ((< time-now 12) "Good morning") ((< time-now 18) "Good afternoon") (else "Good evening")))) ` } }
JS Interoperability
See BiwaScheme docs.
Language Info
Name
scheme
Extensions
.scm
Editor
script
Compiler
BiwaScheme, a Scheme interpreter written in JavaScript.
Version
biwascheme: v0.8.0
Code Formatting
Using Parinfer.
Limitations
BiwaScheme implements most of the features of R7RS small, however some features are not supported. See the BiwaScheme documentation for more information.
Starter Template
https://livecodes.io/?template=scheme