Counter and Theme Toggle - Scheme Typing CST Test
Loading…
Counter and Theme Toggle — Scheme Code
Demonstrates a simple counter with theme toggling using Scheme variables and console output.
(define count 0)
(define isDark #f)
(define (updateUI)
(display "Counter: ") (display count) (newline)
(display "Theme: ") (display (if isDark "Dark" "Light")) (newline))
(define (increment)
(set! count (+ count 1))
(updateUI))
(define (decrement)
(set! count (- count 1))
(updateUI))
(define (reset)
(set! count 0)
(updateUI))
(define (toggleTheme)
(set! isDark (not isDark))
(updateUI))
; Simulate actions
(updateUI)
(increment)
(increment)
(toggleTheme)
(decrement)
(reset)Scheme Language Guide
Scheme is a minimalist, functional programming language in the Lisp family, emphasizing recursion, first-class functions, and symbolic computation. It is widely used in education, research, and AI for its simplicity and powerful abstraction capabilities.
Primary Use Cases
- ▸Functional programming education
- ▸Symbolic computation and AI
- ▸DSL (domain-specific language) design
- ▸Prototyping algorithms
- ▸Scripting within research software
- ▸Teaching recursion and higher-order functions
Notable Features
- ▸Minimalist syntax and semantics
- ▸First-class functions and closures
- ▸Tail-call optimization
- ▸Powerful macro system
- ▸Lexical scoping and recursion
Origin & Creator
Scheme was developed in the 1970s by Guy L. Steele and Gerald Jay Sussman at MIT as a simplified, cleaner dialect of Lisp.
Industrial Note
Scheme is primarily used in academia, language design research, AI prototyping, symbolic mathematics, and educational platforms like introductory computer science courses.