python like datastructures as databases code examples
Serg Gini
kornburn at yandex.ru
Mon Jul 21 08:31:42 UTC 2025
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)));
}
```
More information about the Digitalmars-d-learn
mailing list