Skip to content

Instantly share code, notes, and snippets.

@criloz
Created June 2, 2020 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save criloz/4fd73f02b0c0a6ef1c6da267083d1c12 to your computer and use it in GitHub Desktop.
Save criloz/4fd73f02b0c0a6ef1c6da267083d1c12 to your computer and use it in GitHub Desktop.
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 = `patricia@nebtex.com`;
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