Created
June 2, 2020 22:53
-
-
Save criloz/4fd73f02b0c0a6ef1c6da267083d1c12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn with_email(x){ | |
x.email is r/^[\w\.\+\-]+\@[\w]+\.[a-z]{2,3}$/; | |
return with_email(x); | |
} | |
fn person(x){ | |
x.name is str; | |
x.age is #nat number; | |
return person(x) | |
} | |
fn young(x:person){ | |
x.age < 30; | |
return young(x) | |
} | |
fn old(x:person){ | |
x.age >= 60; | |
return old(x) | |
} | |
fn middle(x:person){ | |
x.age >= 30; | |
x.age < 60; | |
return middle(x) | |
} | |
let patricia = person{name=`patricia`, age=25}; | |
console.log(patricia); | |
patricia.age = 13; | |
console.log(patricia); | |
patricia.age = 70; | |
console.log(patricia); | |
patricia.email = `[email protected]`; | |
console.log(patricia); | |
let arnold = #old person{name=`arnold`, age=70}; | |
//this should raise error because an old person age can only be greater than 60 | |
arnold.age = 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment