guise-lang/examples/literals.guise

41 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2025-11-07 00:08:50 -05:00
;;; Numbers
42 ; Integer
3.14159 ; Float
-17 ; Negative integer
-2.5 ; Negative float
;;; Strings
"hello" ; Simple string
"hello world" ; String with spaces
"" ; Empty string
;;; Booleans
#t ; True
#f ; False
;;; Characters
#\a ; Letter
#\A ; Uppercase
#\space ; Space character
#\newline ; Newline character
#\tab ; Tab character
;;; Lists (using vector syntax)
#() ; Empty list
#(1 2 3) ; List of integers
#("a" "b" "c") ; List of strings
#(#t #f) ; List of booleans
;;; Nested lists (homogeneous - list of lists of int)
#(#(1 2) #(3 4) #(5 6)) ; List of int lists
#(#() #(1) #(2 3)) ; List of int lists (including empty)
;;; Note: Mixed-type lists are not allowed in Guise's static type system
;;; Each list must contain elements of the same type
;;; #(1 "two" #t) ; ERROR: type mismatch
;;; Quotations (code as data)
'(dup *) ; Quotation - code block
'(1 +) ; Quotation - increment function
'() ; Empty quotation