Skip to content

Commit a92dac9

Browse files
authored
Merge pull request #89 from GaragePixel/develop
Syntax addition - Minmax stuff
2 parents fa35ece + bbaa21e commit a92dac9

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,42 @@ Namespace std.syntax
55
'iDkP from GaragePixel
66
'Since 2018-2025
77

8+
'Note: In monkey library, the bad implemented min/max functions must be deactivated
9+
'in order to make the multitypes min/max functions to works
10+
11+
Function Min<T>:T(a:T,b:T) Where T Implements INumeric
12+
'the limit value, if returned, is casted to the initial type
13+
Return a<b ? a Else b
14+
End
15+
816
Function Min<T1,T2>:T1(a:T1,b:T2) Where T1 Implements INumeric And
917
T2 Implements INumeric
1018
'the limit value, if returned, is casted to the initial type
1119
Return Cast<T1>(a<b ? a Else b)
1220
End
1321

22+
1423
Function Min<T>:T Ptr(a:T Ptr,b:T Ptr) Where T Implements INumeric
1524

1625
Return a[0]<b[0] ? a Else b
1726
End
1827

19-
'Function Min<T>:T(a:T Ptr,b:T Ptr) Where T Implements INumeric
20-
' 'return type overload?
21-
' Return a[0]<b[0] ? a[0] Else b[0]
22-
'End
28+
Function Min<T>:T(a:T Ptr,b:T Ptr) Where T Implements INumeric
29+
'return type overload?
30+
Return a[0]<b[0] ? a[0] Else b[0]
31+
End
2332

24-
Function Min<T1,T2>:T1(a:T1 Ptr,b:T2 Ptr) Where T1 Implements INumeric And
33+
Function Min<T1,T2>:T1(a:T1 Ptr,b:T2 Ptr) Where T1 Implements INumeric And
2534
T2 Implements INumeric
2635
'the limit value, if returned, is casted to the initial type
2736
Return Cast<T1>(a[0]<b[0] ? a[0] Else b[0])
2837
End
2938

3039
Function Min<T>:T(a:T,b:T,c:T) Where T Implements INumeric
40+
41+
'3 arguments breaks the overloading of the language min/max stuff
42+
'So the language library non-native stuff was undoned,
43+
'and in the the word we'll have peace!
3144

3245
Return a<b ? (a<c ? a Else c) Else (b<c ? c Else b)
3346
End
@@ -51,6 +64,10 @@ Function Min<T1,T2,T3>:T1(a:T1 Ptr,b:T2 Ptr,c:T3 Ptr) Where T1 Implements INu
5164
Return Cast<T1>(a[0]<b[0] ? (a[0]<c[0] ? a[0] Else c[0]) Else (b[0]<c[0] ? b[0] Else c[0]))
5265
End
5366

67+
Function Max<T>:T(a:T,b:T) Where T Implements INumeric
68+
Return a<b ? b Else a
69+
End
70+
5471
Function Max<T1,T2>:T1(a:T1,b:T2) Where T1 Implements INumeric And
5572
T2 Implements INumeric
5673
Return a<b ? b Else a

modules/std/syntax/syntax.xw

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Namespace std.syntax
1313
#Import "pointers/pointers"
1414

1515
#Import "funcs/reflection"
16+
#Import "funcs/minmax"
1617
#Import "funcs/swaps"
1718
#Import "funcs/clippers/clips"
1819
#Import "funcs/clippers/trims"

0 commit comments

Comments
 (0)