https://forum.dlang.org/post/eih04u$1463$1...@digitaldaemon.com
A version of the code that takes `T which` as a parameter instead
of `int index`.
```
// remove an item from an array
template drop(T)
{
T drop( inout T[] arr, T which )
{
int i;
T resu
On 4/4/22 16:15, Enjoys Math wrote:
> https://forum.dlang.org/post/eih04u$1463$1...@digitaldaemon.com
2006 is a long time ago. :)
> A version of the code that takes `T which` as a parameter instead of
> `int index`.
>
> ```
> // remove an item from an array
> template drop(T)
> {
>T drop( in
On Monday, 4 April 2022 at 23:15:30 UTC, Enjoys Math wrote:
```d
// remove an item from an array
template drop(T)
{
T drop( inout T[] arr, T which )
{
int i;
T result;
for (i=0; i < arr.length; i++)
{
On 4/4/22 7:15 PM, Enjoys Math wrote:
https://forum.dlang.org/post/eih04u$1463$1...@digitaldaemon.com
A version of the code that takes `T which` as a parameter instead of
`int index`.
```
// remove an item from an array
template drop(T)
{
T drop( inout T[] arr, T which )
Note to reader:
On Tuesday, 5 April 2022 at 14:10:44 UTC, Steven Schveighoffer
wrote:
I'd implement it probably like this (for D2):
```d
auto drop(T)(ref T[] arr, T which)
{
import std.algorithm, std.range;
auto f = arr.find(which);
debug if(f.empty) throw ...;
auto result = arr.front;
arr = arr.
On 4/5/22 11:43 AM, Paul Backus wrote:
On Tuesday, 5 April 2022 at 14:10:44 UTC, Steven Schveighoffer wrote:
I'd implement it probably like this (for D2):
```d
auto drop(T)(ref T[] arr, T which)
{
import std.algorithm, std.range;
auto f = arr.find(which);
debug if(f.empty) throw ...;
On Tuesday, 5 April 2022 at 14:10:44 UTC, Steven Schveighoffer
wrote:
[...]
I'd implement it probably like this (for D2):
```d
auto drop(T)(ref T[] arr, T which)
{
import std.algorithm, std.range;
auto f = arr.find(which);
debug if(f.empty) throw ...;
auto result = arr.front;
arr
On 4/5/22 11:47 PM, Salih Dincer wrote:
On Tuesday, 5 April 2022 at 14:10:44 UTC, Steven Schveighoffer wrote:
[...]
I'd implement it probably like this (for D2):
```d
auto drop(T)(ref T[] arr, T which)
{
import std.algorithm, std.range;
auto f = arr.find(which);
debug if(f.empty) throw
On Wednesday, 6 April 2022 at 16:54:26 UTC, Steven Schveighoffer
wrote:
This is almost equivalent, but it requires a lambda and an
allocation. So I'm not sure what thing you are trying to do
here.
I tried to get these results but it didn't work:
abc
efg
h
[0, 3]
[4, 7]
[8, 9]
abcefgh
I'm
On 4/6/22 2:32 PM, Salih Dincer wrote:
On Wednesday, 6 April 2022 at 16:54:26 UTC, Steven Schveighoffer wrote:
This is almost equivalent, but it requires a lambda and an allocation.
So I'm not sure what thing you are trying to do here.
**Source Code:**
https://forum.dlang.org/post/pxkhngx
On Wednesday, 6 April 2022 at 19:28:53 UTC, Steven Schveighoffer
wrote:
With `arr.find!(someLambda)`, if the lambda is using data from
outside the lambda, it needs a closure, which means it may
(probably does) allocate your needed data into a GC heap block
that will then become garbage after th
11 matches
Mail list logo