https://github.com/jrincayc/ucblogo-code
Raw File
Tip revision: 83cc26c4471bbf5be58589e2f43a4caba6b98469 authored by Joshua J. Cogliati on 26 December 2019, 17:49:01 UTC
Adding source code to windows install
Tip revision: 83cc26c
cond
;;; -*- logo -*-

.macro cond :cond.clauses
localmake "cond.result cond.helper :cond.clauses
if equalp first :cond.result "error [(throw "error last :cond.result)]
output last :cond.result
end

to cond.helper :cond.clauses
if emptyp :cond.clauses [output [[] []]]
if emptyp first :cond.clauses [output [error [Empty COND clause]]]
if equalp first first :cond.clauses "else ~
   [output list [] butfirst first :cond.clauses]
ignore error
catch "error [localmake "cond.result run first first :cond.clauses]
localmake "cond.error error
if not emptyp :cond.error [output list "error item 2 :cond.error]
if not memberp :cond.result [true false] ~
   [output list "error fput :cond.result [not TRUE or FALSE]]
if :cond.result [output list [] butfirst first :cond.clauses]
output cond.helper butfirst :cond.clauses
end

bury [cond cond.helper]
back to top