From b5348948e90c57585968fece57db4b5313cac2c8 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 04:55:10 +0200 Subject: [PATCH 01/10] Update syntax.xw --- modules/std/syntax/syntax.xw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/std/syntax/syntax.xw b/modules/std/syntax/syntax.xw index e62ca9ad..14ba6afb 100644 --- a/modules/std/syntax/syntax.xw +++ b/modules/std/syntax/syntax.xw @@ -24,5 +24,5 @@ Namespace std.syntax #Import "functors/vattribs" #Import "functors/attribs" -#Import "aliases/aliases" +#Import "aliases/prefixes" From fb87fa2c0935f8fc2a5eb4a9e7341dee4e3d95dd Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 04:56:16 +0200 Subject: [PATCH 02/10] Update syntax.xw --- modules/std/syntax/syntax.xw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/std/syntax/syntax.xw b/modules/std/syntax/syntax.xw index 14ba6afb..e62ca9ad 100644 --- a/modules/std/syntax/syntax.xw +++ b/modules/std/syntax/syntax.xw @@ -24,5 +24,5 @@ Namespace std.syntax #Import "functors/vattribs" #Import "functors/attribs" -#Import "aliases/prefixes" +#Import "aliases/aliases" From 3d1cdc7d3e76cccd19da620a57e3176892eb3722 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 04:58:46 +0200 Subject: [PATCH 03/10] Update map.wx --- modules/std/collections/map.wx | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/modules/std/collections/map.wx b/modules/std/collections/map.wx index 706b5990..332aa9df 100644 --- a/modules/std/collections/map.wx +++ b/modules/std/collections/map.wx @@ -843,7 +843,46 @@ Class Map If node Return node._value Return Null End + + #rem monkeydoc Search if a contained value exists as the value of a key. + @author iDkP from GaragePixel + @since 2025-07-18 + @param key The key. + @param key The values container. Accepts [[Array]], [[Stack]] and [[List]]. + @return -1 if the key hasn't any contained values, or an index corresponding to the value's position in the container. + #end + Method Search:Int( key:K,values:Stack ) + 'Added by iDkP from GaragePixel 2025-07-18 + Return Search(key,values.Data) + End + Method Search:Int( key:K,values:V[] ) + 'Added by iDkP from GaragePixel 2025-07-18 + Local keynode:=FindNode(key) + If keynode + Local value:=FindNode(key).Value + Local valuesLength:=values.Length + For Local index:=0 Until valuesLength + If value=values[index] Return index + End + End + Return -1 + End + + Method Search:Int( key:K,values:List ) + 'Added by iDkP from GaragePixel 2025-07-18 + Local keynode:=FindNode(key) + If keynode + Local value:=keynode.Value + Local index:Int=0 + For Local item:=Eachin values + If value=item Return index + index+=1 + End + End + Return -1 + End + #rem wonkeydoc Removes a key from the map. @param key The key to remove. @return True if the key was removed, or false if the key is not in the map. From 2a9f1e5b47b8806bc6ba9f34c94cfd061cac0e28 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 04:59:51 +0200 Subject: [PATCH 04/10] Update map.wx --- modules/std/collections/map.wx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/std/collections/map.wx b/modules/std/collections/map.wx index 332aa9df..e4fb913c 100644 --- a/modules/std/collections/map.wx +++ b/modules/std/collections/map.wx @@ -844,7 +844,7 @@ Class Map Return Null End - #rem monkeydoc Search if a contained value exists as the value of a key. + #rem wonkeydoc Search if a contained value exists as the value of a key. @author iDkP from GaragePixel @since 2025-07-18 @param key The key. From 633ce6144b98c5cb501f1206cb5de3ab868bc6f1 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 05:45:12 +0200 Subject: [PATCH 05/10] Update syntax.xw --- modules/std/syntax/syntax.xw | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/std/syntax/syntax.xw b/modules/std/syntax/syntax.xw index e62ca9ad..ea82bceb 100644 --- a/modules/std/syntax/syntax.xw +++ b/modules/std/syntax/syntax.xw @@ -20,9 +20,11 @@ Namespace std.syntax #Import "funcs/clippers/wraps" #Import "funcs/clippers/frames" -#Import "functors/foreach" #Import "functors/vattribs" #Import "functors/attribs" +#Import "functors/foreach" +#Import "functors/assignif" +#Import "functors/ifelse" #Import "aliases/aliases" From 6b48f7067822f340fa0643c62f65a393887c9be2 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 05:45:54 +0200 Subject: [PATCH 06/10] Create assignif.wx --- modules/std/syntax/functors/assignif.wx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 modules/std/syntax/functors/assignif.wx diff --git a/modules/std/syntax/functors/assignif.wx b/modules/std/syntax/functors/assignif.wx new file mode 100644 index 00000000..f27af936 --- /dev/null +++ b/modules/std/syntax/functors/assignif.wx @@ -0,0 +1,14 @@ + +Namespace std.syntax + +#rem monkeydoc @pro Assigns something if not null. +@author iDkP from GagagePixel +@since 2025-07-18 +If callback_NotNull is null, target's value is left intact +So, instead of to write the content of this function in-code, +we can just wrote AssignIf(eval(),Varptr(myVar)) +#end +Function AssignIf( callback_NotNull:T(),target:T Ptr ) + Local result:=callback_NotNull() + If result target[0] = result +End From dff3d67890d84a88502a474db7496917b6bb0e66 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 05:46:58 +0200 Subject: [PATCH 07/10] Create ifelse.wx --- modules/std/syntax/functors/ifelse.wx | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 modules/std/syntax/functors/ifelse.wx diff --git a/modules/std/syntax/functors/ifelse.wx b/modules/std/syntax/functors/ifelse.wx new file mode 100644 index 00000000..5031f926 --- /dev/null +++ b/modules/std/syntax/functors/ifelse.wx @@ -0,0 +1,29 @@ + +Namespace std.syntax + +#rem monkeydoc @pro It's the ternary but function styled. +@author iDkP from GagagePixel +@since 2025-07-18 +@param eval/state: any values not null +@param callbackTrue/options1 evaluated/stated variable returned if eval/state is not null +@param callbackFalse/options2 evaluated/stated variable returned if eval/state is not null +@return If val is not null/false, returns callbackTrue/option1's value +@return If val is null/false, returns the callbackFalse/option2's value +@example + Local myValue:=IfElse(evalThis,thenDoReturnThat,elseDoReturnThat) +#end +Function IfElse:T( eval:T(),callbackTrue:T(),callbackFalse:T()=Null ) + If eval Return callbackTrue() + Return callbackFalse() +End + +Function IfElse:T( eval:T(),option1:T,option2:T=Null ) + If eval Return option1 + Return option2 +End + +Function IfElse:T( state:T,option1:T,option2:T=Null ) + If eval Return option1 + Return option2 +End + From 87ffe5daea82da99dfa9487da4f35d96686b5856 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 05:53:16 +0200 Subject: [PATCH 08/10] Create searchin.wx --- modules/std/syntax/funcs/searchin.wx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 modules/std/syntax/funcs/searchin.wx diff --git a/modules/std/syntax/funcs/searchin.wx b/modules/std/syntax/funcs/searchin.wx new file mode 100644 index 00000000..9ef6d40f --- /dev/null +++ b/modules/std/syntax/funcs/searchin.wx @@ -0,0 +1,18 @@ + +Namespace std.syntax + +#rem monkeydoc @pro @sugar SearchIn collections functions. +@author iDkP from GagagePixel +@since 2025-07-18 +#end +Function SearchIn:Int( map:Map,key:K,values:Stack ) + Return map.Search( key, values.Data ) +End + +Function SearchIn:Int( map:Map,key:K,values:V[] ) + Return map.Search( key, values ) +End + +Function SearchIn:Int( map:Map,key:K,values:List ) + Return map.Search( key, values ) +End From 457ced32dcc0e415f1b93710e6c4bcf3ca9d1474 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 06:53:35 +0200 Subject: [PATCH 09/10] Update assignif.wx --- modules/std/syntax/functors/assignif.wx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/std/syntax/functors/assignif.wx b/modules/std/syntax/functors/assignif.wx index f27af936..7371026e 100644 --- a/modules/std/syntax/functors/assignif.wx +++ b/modules/std/syntax/functors/assignif.wx @@ -12,3 +12,15 @@ Function AssignIf( callback_NotNull:T(),target:T Ptr ) Local result:=callback_NotNull() If result target[0] = result End + +#rem monkeydoc @pro Assigns something if not null or false. +@author iDkP from GagagePixel +@since 2025-07-18 +If callback_NotNull is null or false, target's value is left intact +So, instead of to write the content of this function in-code, +we can just wrote AssignIff(eval(),Varptr(myVar)) +#end +Function AssignIff( callback_NotNull:T(),target:T Ptr ) + Local result:=callback_NotNull() + If result And result<>False target[0] = result +End From cc602fbbcb27e1a25414b316274a76654a377176 Mon Sep 17 00:00:00 2001 From: GaragePixel Date: Fri, 18 Jul 2025 06:53:47 +0200 Subject: [PATCH 10/10] Update assignif.wx --- modules/std/syntax/functors/assignif.wx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/std/syntax/functors/assignif.wx b/modules/std/syntax/functors/assignif.wx index 7371026e..0968c2bd 100644 --- a/modules/std/syntax/functors/assignif.wx +++ b/modules/std/syntax/functors/assignif.wx @@ -1,7 +1,7 @@ Namespace std.syntax -#rem monkeydoc @pro Assigns something if not null. +#rem wonkeydoc @pro Assigns something if not null. @author iDkP from GagagePixel @since 2025-07-18 If callback_NotNull is null, target's value is left intact @@ -13,7 +13,7 @@ Function AssignIf( callback_NotNull:T(),target:T Ptr ) If result target[0] = result End -#rem monkeydoc @pro Assigns something if not null or false. +#rem wonkeydoc @pro Assigns something if not null or false. @author iDkP from GagagePixel @since 2025-07-18 If callback_NotNull is null or false, target's value is left intact