June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
4
Task/Extend-your-language/ABAP/extend-your-language.abap
Normal file
4
Task/Extend-your-language/ABAP/extend-your-language.abap
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
DATA(result) = COND #( WHEN condition1istrue = abap_true AND condition2istrue = abap_true THEN bothconditionsaretrue
|
||||
WHEN condition1istrue = abap_true THEN firstconditionistrue
|
||||
WHEN condition2istrue = abap_true THEN secondconditionistrue
|
||||
ELSE noconditionistrue ).
|
||||
4
Task/Extend-your-language/DUP/extend-your-language-1.dup
Normal file
4
Task/Extend-your-language/DUP/extend-your-language-1.dup
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{two-conditional if operator implementation}
|
||||
{ [ top cond. = true ][ top cond. = false ]}
|
||||
{ [ 2nd = true ][2nd = false ] [ 2nd = true ][ 2nd = false] }
|
||||
[(((([[)))!)))%%%%%][)))))!)%%%%%]?][[))))!))%%%%%][))))))!%%%%%]?]?]⇒¿
|
||||
1
Task/Extend-your-language/DUP/extend-your-language-2.dup
Normal file
1
Task/Extend-your-language/DUP/extend-your-language-2.dup
Normal file
|
|
@ -0,0 +1 @@
|
|||
0 1_['t,'t,]['t,'f,]['f,'t,]['f,'f,]¿
|
||||
51
Task/Extend-your-language/Fortran/extend-your-language-1.f
Normal file
51
Task/Extend-your-language/Fortran/extend-your-language-1.f
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
LOGICAL A,B !These are allocated the same storage
|
||||
INTEGER IA,IB !As the default integer size.
|
||||
EQUIVALENCE (IA,A),(IB,B) !So, this will cause no overlaps.
|
||||
|
||||
WRITE (6,*) "Boolean tests via integers..."
|
||||
DO 199 IA = 0,1 !Two states for A.
|
||||
DO 199 IB = 0,1 !Two states for B.
|
||||
IF (IA) 666,99,109 !Not four ways, just three.
|
||||
99 IF (IB) 666,100,101 !Negative values are surely wrong.
|
||||
100 WRITE (6,*) "FF",IA,IB
|
||||
GO TO 199
|
||||
101 WRITE (6,*) "FT",IA,IB
|
||||
GO TO 199
|
||||
109 IF (IB) 666,110,111 !A second test.
|
||||
110 WRITE (6,*) "TF",IA,IB
|
||||
GO TO 199
|
||||
111 WRITE (6,*) "TT",IA,IB
|
||||
199 CONTINUE !Both loops finish here.
|
||||
|
||||
WRITE (6,*) "Boolean tests via integers and computed GO TO..."
|
||||
DO 299 IA = 0,1 !Two states for A.
|
||||
DO 299 IB = 0,1 !Two states for B.
|
||||
GO TO (200,201,210,211) 1 + IA*2 + IB !Counting starts with one.
|
||||
200 WRITE (6,*) "FF",IA,IB
|
||||
GO TO 299
|
||||
201 WRITE (6,*) "FT",IA,IB
|
||||
GO TO 299
|
||||
210 WRITE (6,*) "TF",IA,IB
|
||||
GO TO 299
|
||||
211 WRITE (6,*) "TT",IA,IB
|
||||
299 CONTINUE !Both loops finish here.
|
||||
|
||||
300 WRITE (6,301)
|
||||
301 FORMAT (/,"Boolean tests via LOGICAL variables...",/
|
||||
1 " AB IA IB (IA*2 + IB)")
|
||||
A = .TRUE. !Syncopation.
|
||||
B = .TRUE. !Via the .NOT., the first pair will be FF.
|
||||
DO I = 0,1 !Step through two states.
|
||||
A = .NOT.A !Thus generate F then T.
|
||||
DO J = 0,1 !Step through the second two states.
|
||||
B = .NOT.B !Thus generate FF, FT, TF, TT.
|
||||
WRITE (6,302) A,B,IA,IB,IA*2 + IB !But with strange values.
|
||||
302 FORMAT (1X,2L1,2I6,I8) !Show both types.
|
||||
END DO !Next value for B.
|
||||
END DO !Next value for A.
|
||||
GO TO 999
|
||||
|
||||
666 WRITE (6,*) "Huh?"
|
||||
|
||||
999 CONTINUE
|
||||
END
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
INTEGER FUNCTION IF2(A,B) !Combine two LOGICAL variables.
|
||||
LOGICAL A,B !These.
|
||||
IF2 = 0 !Wasted effort if A is true.
|
||||
IF (A) IF2 = 2 !But it avoids IF ... THEN ... ELSE ... END IF blather.
|
||||
IF (B) IF2 = IF2 + 1 !This relies on IF2 being a variable. (Standard in F90+)
|
||||
END FUNCTION IF2 !Thus produce a four-way result.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
SELECT CASE(IF2(A,B))
|
||||
CASE(B"00"); WRITE (6,*) "Both false."
|
||||
CASE(B"01"); WRITE (6,*) "B only."
|
||||
CASE(B"10"); WRITE (6,*) "A only."
|
||||
CASE(B"11"); WRITE (6,*) "Both true."
|
||||
END SELECT
|
||||
58
Task/Extend-your-language/Go/extend-your-language.go
Normal file
58
Task/Extend-your-language/Go/extend-your-language.go
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type F func()
|
||||
|
||||
type If2 struct {cond1, cond2 bool}
|
||||
|
||||
func (i If2) else1(f F) If2 {
|
||||
if i.cond1 && !i.cond2 {
|
||||
f()
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func (i If2) else2(f F) If2 {
|
||||
if i.cond2 && !i.cond1 {
|
||||
f()
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func (i If2) else0(f F) If2 {
|
||||
if !i.cond1 && !i.cond2 {
|
||||
f()
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func if2(cond1, cond2 bool, f F) If2 {
|
||||
if cond1 && cond2 {
|
||||
f()
|
||||
}
|
||||
return If2{cond1, cond2}
|
||||
}
|
||||
|
||||
func main() {
|
||||
a, b := 0, 1
|
||||
if2 (a == 1, b == 3, func() {
|
||||
fmt.Println("a = 1 and b = 3")
|
||||
}).else1 (func() {
|
||||
fmt.Println("a = 1 and b <> 3")
|
||||
}).else2 (func() {
|
||||
fmt.Println("a <> 1 and b = 3")
|
||||
}).else0 (func() {
|
||||
fmt.Println("a <> 1 and b <> 3")
|
||||
})
|
||||
|
||||
// It's also possible to omit any (or all) of the 'else' clauses or to call them out of order
|
||||
a, b = 1, 0
|
||||
if2 (a == 1, b == 3, func() {
|
||||
fmt.Println("a = 1 and b = 3")
|
||||
}).else0 (func() {
|
||||
fmt.Println("a <> 1 and b <> 3")
|
||||
}).else1 (func() {
|
||||
fmt.Println("a = 1 and b <> 3")
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
if2 : Bool -> Bool -> Lazy a -> Lazy a -> Lazy a -> Lazy a -> a
|
||||
if2 True True v _ _ _ = v
|
||||
if2 True False _ v _ _ = v
|
||||
if2 False True _ _ v _ = v
|
||||
if2 _ _ _ _ _ v = v
|
||||
26
Task/Extend-your-language/Ring/extend-your-language.ring
Normal file
26
Task/Extend-your-language/Ring/extend-your-language.ring
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Project : Extend your language
|
||||
# Date : 2017/11/15
|
||||
# Author : Gal Zsolt (~ CalmoSoft ~)
|
||||
# Email : <calmosoft@gmail.com>
|
||||
|
||||
see "a = 1, b = 1 => "
|
||||
test(1, 1)
|
||||
see "a = 1, b = 0 => "
|
||||
test(1, 0)
|
||||
see "a = 0, b = 1 => "
|
||||
test(0, 1)
|
||||
see "a = 0, b = 0 => "
|
||||
test(0, 0)
|
||||
see nl
|
||||
|
||||
func test(a,b)
|
||||
if a > 0 and b > 0
|
||||
see "both positive"
|
||||
but a > 0
|
||||
see "first positive"
|
||||
but b > 0
|
||||
see "second positive"
|
||||
but a < 1 and b < 1
|
||||
see "neither positive"
|
||||
ok
|
||||
see nl
|
||||
Loading…
Add table
Add a link
Reference in a new issue