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 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(
A plot twist. I actually used Golang for submitting all my
solutions in the qualification round:
https://codingcompetitions.withgoogle.com/codejam/submissions/00876ff1/0048a518
The reason is that right now I'm switching to Golang at work. And
Code Jam tasks are a good practice
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
```
C:\Users\FruitfulApproach\Desktop\BananaCats\BananaCatsInD\pyd\infrastructure\pyd\make_object.d(1190):
Deprecation: returning `` escapes a reference to parameter `this`
C:\Users\FruitfulApproach\Desktop\BananaCats\BananaCatsInD\pyd\infrastructure\pyd\make_object.d(1190):
perhaps
On 4/4/22 13:37, H. S. Teoh wrote:
>> I remember reading somewhat similar requests in the past: Assign to a
>> variable freely but at some point say "no more mutation to this
>> variable".
> [...]
>
> It's not just "assign freely"; it's "assign once". Or rather, "assign
> before the outside
On Mon, Apr 04, 2022 at 11:20:31AM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
> On 4/3/22 17:42, H. S. Teoh wrote:
>
> > In some sense, this is like an extension of ctors initializing
> > immutable values. The compiler tracks whether the variable has been
> > initialized yet, and inside
On 4/3/22 17:42, H. S. Teoh wrote:
> In some sense, this is like an extension of ctors initializing immutable
> values. The compiler tracks whether the variable has been initialized
> yet, and inside the ctor you can assign to immutable because the
> uninitialized value is not observable from
On Monday, 4 April 2022 at 13:32:19 UTC, Steven Schveighoffer
wrote:
This looks more like lisp or scheme. You know this is a forum
for the D programming language?
This was the same question in my mind.
On Monday, 4 April 2022 at 12:57:28 UTC, V3nom wrote:
define the lists:
(define liste (cons 10(cons 20(cons 30(cons 40 ' ())
(define liste2 (cons 20(cons 30(cons 10(cons 40 ' ())
define the "function":
(define (listapp list1 list2)(
if (null? (cdr list1))
On 4/4/22 8:57 AM, V3nom wrote:
define the lists:
(define liste (cons 10(cons 20(cons 30(cons 40 ' ())
(define liste2 (cons 20(cons 30(cons 10(cons 40 ' ())
This looks more like lisp or scheme. You know this is a forum for the D
programming language?
-Steve
define the lists:
(define liste (cons 10(cons 20(cons 30(cons 40 ' ())
(define liste2 (cons 20(cons 30(cons 10(cons 40 ' ())
define the "function":
(define (listapp list1 list2)(
if (null? (cdr list1))
(cons (car list1) (listapp list2 (cdr list1)))
On Monday, 4 April 2022 at 09:26:13 UTC, Stanislav Blinov wrote:
No. Neither `malloc` nor `realloc` (for which D's `pure...`
variants are mere wrappers) are specified to initialize
allocated memory. `calloc`, however, is - it initializes
allocated block with zeroes.
Thanks, that's what I was
On Monday, 4 April 2022 at 07:48:40 UTC, rempas wrote:
Maybe, I didn't explained it properly. The example works.
However, I wonder if it randomly works or if it is safe to do
something like that as if the bytes have been initialized to
'\0'.
```d
import core.memory : pureMalloc;
import
On Monday, 4 April 2022 at 07:32:00 UTC, rempas wrote:
In other terms, do these functions auto-initialize memory to be
ready for use?
No. Neither `malloc` nor `realloc` (for which D's `pure...`
variants are mere wrappers) are specified to initialize allocated
memory. `calloc`, however, is -
On Monday, 4 April 2022 at 07:39:08 UTC, Salih Dincer wrote:
On Monday, 4 April 2022 at 07:32:00 UTC, rempas wrote:
Does anyone knows what's going on here?
Source code?
Why does it matter?
```
import core.memory;
import core.stdc.stdio;
import core.stdc.stdlib;
extern (C) void main() {
On Monday, 4 April 2022 at 07:32:00 UTC, rempas wrote:
Does anyone knows what's going on here?
Source code?
In other terms, do these functions auto-initialize memory to be
ready for use? I test it out using `printf` to print a string.
"%s" expects for a null terminated string and it seems to work so
I suppose that these functions auto-initialize the bytes to `\0`.
However, memory is tricky and I
18 matches
Mail list logo