Shen, copyright (C) 2010-2020 Mark Tarver
www.shenlanguage.org, Shen Professional Edition 33.03
running under Common Lisp, implementation: SBCL
port 3.2 ported by Mark Tarver
commercially licensed to Mark Tarver
(0-) (datatype age
if (number? Age)
if (>= Age 18)
if (<= Age 64)
____________
Age : age;)
age#type
(1-)
(datatype department
if (element? D [wages recruitment sales advertising])
____________________________________________________
D : department;)
department#type
(2-)
(datatype record
N : string; A : age; D : department;
____________________________________
[N A D] : record;)
record#type
(3+) (define get-age
{string --> (list record) --> age}
_ [] -> (error "no details for this name~%")
N [[N A D] | _] -> A
N [_ | Records] -> (get-age N Records))
type error in rule 2 of get-age
(4+) (datatype record
N : string; A : age; D : department;
====================================
record#type : symbol
(6+) !3
(define get-age
{string --> (list record) --> age}
_ [] -> (error "no details for this name~%")
N [[N A D] | _] -> A
N [_ | Records] -> (get-age N Records))
(fn get-age) : (string --> ((list record) --> age))
This passes all the standard tests for the kernel and is now in SP.
Kernel revision will appear soon.
Mark