python like datastructures as databases code examples

Monkyyy crazymonkyyy at gmail.com
Mon Jul 21 14:15:07 UTC 2025


On Monday, 21 July 2025 at 08:31:42 UTC, Serg Gini wrote:
> On Friday, 18 July 2025 at 18:35:40 UTC, monkyyy wrote:
>> `shapes.filter(isnt:shapeenum.isstatic)`
>> https://forum.dlang.org/thread/apbcqxiifbsqdlrsluol@forum.dlang.org
>>
>> I know its possible to make complex, datastructure aware 
>> filters, but I never done it
>>
>> what patterns do people use? lets say you have an always 
>> sorted array and the user is asking for values between 100 and 
>> 200 `array.filter(above:100,below:200)`; obviously possible 
>> but maybe theres some details that will make my life easier
>>
>> how yall implement such things?
>
>     ```d
>     bool between(T)(T element, T before, T after) {
>     	return (before < element) & (element < after);
>     }
>
>     void main() {
>         auto arr = [1,2,4,6,7,23,3,7,8,23,1,7,8];
>         writeln(arr.filter!(a => between(a,5,9)));
>     }
>     ```

That filter is not aware of the data structure nor is that array 
maintaining a sort


More information about the Digitalmars-d-learn mailing list