YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
16
Task/Extend-your-language/Agda/extend-your-language.agda
Normal file
16
Task/Extend-your-language/Agda/extend-your-language.agda
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
data Bool : Set where
|
||||
true : Bool
|
||||
false : Bool
|
||||
|
||||
if_then_else : ∀ {l} {A : Set l} -> Bool -> A -> A -> A
|
||||
if true then t else e = t
|
||||
if false then t else e = e
|
||||
|
||||
if2_,_then_else1_else2_else_ : ∀ {l} {A : Set l} -> (b1 b2 : Bool) -> (t e1 e2 e : A) -> A
|
||||
if2 true , true then t else1 e1 else2 e2 else e = t
|
||||
if2 true , false then t else1 e1 else2 e2 else e = e1
|
||||
if2 false , true then t else1 e1 else2 e2 else e = e2
|
||||
if2 false , false then t else1 e1 else2 e2 else e = e
|
||||
|
||||
example : Bool
|
||||
example = if2 true , false then true else1 false else2 true else false
|
||||
|
|
@ -100,12 +100,10 @@ sub if2($$@) {
|
|||
or grep {defined and ref $_ ne 'CODE'} @_;
|
||||
|
||||
my $index;
|
||||
given ([$cond1, $cond2]) {
|
||||
when ([False, False]) {$index = IdxOrElse}
|
||||
when ([False, True ]) {$index = IdxElse2 }
|
||||
when ([True, False]) {$index = IdxElse1 }
|
||||
when ([True, True ]) {$index = IdxThen }
|
||||
}
|
||||
if (!$cond1 && !$cond2) {$index = IdxOrElse}
|
||||
if (!$cond1 && $cond2) {$index = IdxElse2 }
|
||||
if ( $cond1 && !$cond2) {$index = IdxElse1 }
|
||||
if ( $cond1 && $cond2) {$index = IdxThen }
|
||||
|
||||
my $closure = $_[$index];
|
||||
&$closure if defined $closure;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
# Project : Extend your language
|
||||
# Date : 2017/11/15
|
||||
# Author : Gal Zsolt (~ CalmoSoft ~)
|
||||
# Email : <calmosoft@gmail.com>
|
||||
|
||||
see "a = 1, b = 1 => "
|
||||
test(1, 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue