Why after writeln the binaryHeap become empty?

2019-06-18 Thread lili via Digitalmars-d-learn
Hi Guys: see this code ~~~ int[] ar = [1,2,3,4,52,34,22]; auto h = heapify(ar); assert(h.length() == ar.length); writeln("h:",h); assert(h.empty()); ~~~ dmd v2.086.0 run all assert passed. Why?

Re: Why after writeln the binaryHeap become empty?

2019-06-18 Thread lili via Digitalmars-d-learn
On Tuesday, 18 June 2019 at 17:25:51 UTC, Johannes Loher wrote: The result of heapify is a BinaryHeap, which is a range. writeln basically prints ranges by iterating over them and printing each element (except for the types which are special cased, such as dynamic arrays etc.). However, ranges

Re: Where can find fix length array memory layout document

2019-06-18 Thread lili via Digitalmars-d-learn
On Tuesday, 18 June 2019 at 17:29:49 UTC, Cym13 wrote: On Tuesday, 18 June 2019 at 17:25:42 UTC, Cym13 wrote: On Tuesday, 18 June 2019 at 13:05:03 UTC, lili wrote: On Tuesday, 18 June 2019 at 12:39:45 UTC, Dennis wrote: [...] Thanks a lot, where is a core.stdcpp.array , How to user it? I

Where can find dmd back-end source code.

2019-06-17 Thread lili via Digitalmars-d-learn
Hi gues: I clone the dmd source code from github but i can find backend code. there is a backend dir in src but can not find x86 native code generator. and the dmd wiki page just say Back end FileFunction html.c Extracts D source code from .html files but source can't find html.c

What is the difference between extern(C++) extern(D)

2019-06-19 Thread lili via Digitalmars-d-learn
Hi Guys; In the dmd source code, has lot of extern (C++), Why need this and what is difference between extern(C++) extern(D), Thanks your answer.

Re: Where can find fix length array memory layout document

2019-06-19 Thread lili via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 12:53:05 UTC, Cym13 wrote: Did you import it properly? ``` void main() { import core.stdcpp.array; auto a = array!(int, 4)(); } ``` compiles and runs without issue for me. You'll have to show your code if you want people to help you

What is iota function full name

2019-06-21 Thread lili via Digitalmars-d-learn
Hi Guys: What is range.iota function full name

Re: What is iota function full name

2019-06-21 Thread lili via Digitalmars-d-learn
On Friday, 21 June 2019 at 09:09:33 UTC, aliak wrote: On Friday, 21 June 2019 at 09:01:17 UTC, lili wrote: Hi Guys: What is range.iota function full name That is the full name. Or what do you mean? Found on the internet somewhere: "The function is named after the integer function ⍳ from

There is a computer languages benchmark compare site, but no Dlang benchmark. I think they should support D.

2019-06-21 Thread lili via Digitalmars-d-learn
A nick site, has a lot of languages, unfortunately no dlang in there. https://benchmarksgame-team.pages.debian.net/benchmarksgame/

Re: Where can find fix length array memory layout document

2019-06-18 Thread lili via Digitalmars-d-learn
On Tuesday, 18 June 2019 at 12:39:45 UTC, Dennis wrote: On Tuesday, 18 June 2019 at 12:26:14 UTC, lili wrote: Hi guys: Is the Dlang fix-length array alloc on stack? when a test writeln([1]).sizeof //16 writeln([2]).sizeof //16 Why, What is the fix-length array memory layout.

Where can find fix length array memory layout document

2019-06-18 Thread lili via Digitalmars-d-learn
Hi guys: Is the Dlang fix-length array alloc on stack? when a test writeln([1]).sizeof //16 writeln([2]).sizeof //16 Why, What is the fix-length array memory layout.

Where can find the GC impletement source code?

2019-06-26 Thread lili via Digitalmars-d-learn
Hi Guys: I look for the GC source code in /usr/include/dmd dir, unfortunately not find.

What the abstrac final class mean?

2019-08-12 Thread lili via Digitalmars-d-learn
Hi: Why need defined an abstract final class? see https://github.com/Rikarin/Trinix/blob/master/Kernel/arch/amd64/gdt.d

How to set a global var to a user defined section.

2019-08-20 Thread lili via Digitalmars-d-learn
Hi: With gcc we can use _ attribute _((section("name")) var; how to same in dlang?

[Help!] Use two different assembly symbol in D, but they are same address.

2019-08-24 Thread lili via Digitalmars-d-learn
Hi: definition _vga_x and _vga_y symbol in asm, compile use nasm -f elf64 -o boot.o boot.asm [section .bss] ... [global _vga_x] _vga_x: resb 8 [global _vga_y] _vga_y: resb 8 and nm boot.o show below ... 00107000 B _vga_x 00107008 B _vga_y and

Re: [Help!] Use two different assembly symbol in D, but they are same address.

2019-08-24 Thread lili via Digitalmars-d-learn
On Saturday, 24 August 2019 at 12:09:19 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote: [...] resb 8 just reserving 8 bytes not initializing it. probably u compare some garbage. sometimes it equals, sometimes not. no? I write wrong, not if (_vga_x == _vga_y)

Re: [Help!] Use two different assembly symbol in D, but they are same address.

2019-08-25 Thread lili via Digitalmars-d-learn
On Saturday, 24 August 2019 at 12:55:57 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 12:16:34 UTC, lili wrote: On Saturday, 24 August 2019 at 12:09:19 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote: [...] resb 8 just reserving 8 bytes not initializing it.

How stdin.readf ignore space char?

2019-09-03 Thread lili via Digitalmars-d-learn
Hi guys: input is two line, first line is a number n and second line is n float point number, e.g. 3 1.1 2.2 3.3 how use stdin.readf get all number. i code below but not work well. int n; stdin.readf!"%d\n"(n); writeln("read n:",n);

Re: How stdin.readf ignore space char?

2019-09-03 Thread lili via Digitalmars-d-learn
On Tuesday, 3 September 2019 at 13:21:16 UTC, a11e99z wrote: On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote: Hi guys: input is two line, first line is a number n and second line is n float point number, e.g. 3 1.1 2.2 3.3 how use stdin.readf get all number.

Is there has an pdf document for Phobos.

2019-09-03 Thread lili via Digitalmars-d-learn
Hi: For some reason it too slow that some times i visited dlang.org, Can admin make a pdf document for download.

How to learn Phobos,Phbos hard to used for me.

2019-08-28 Thread lili via Digitalmars-d-learn
Hi: Masters who can write a book for Phbos, the dlang doc not friendly to beginner.

Re: How to learn Phobos,Phbos hard to used for me.

2019-08-28 Thread lili via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 12:32:59 UTC, Andre Pany wrote: On Wednesday, 28 August 2019 at 11:34:27 UTC, lili wrote: Hi: Masters who can write a book for Phbos, the dlang doc not friendly to beginner. There are 2 articles which I really like:

How to write __traits(isSame, T, int) use another way

2019-08-22 Thread lili via Digitalmars-d-learn
Hi: I think the __traits(isSame, T, int) syntax is too uglily, Is where an other way rewrite it. like this isSameType!(T,int)

Re: How to write __traits(isSame, T, int) use another way

2019-08-22 Thread lili via Digitalmars-d-learn
On Thursday, 22 August 2019 at 17:01:09 UTC, Adam D. Ruppe wrote: On Thursday, 22 August 2019 at 16:54:56 UTC, lili wrote: I think the __traits(isSame, T, int) syntax is too uglily, Is where an other way rewrite it. like this isSameType!(T,int) For types you can (and often should) just

How to removes an variable topmost const. like remove_const in C++.

2019-08-22 Thread lili via Digitalmars-d-learn
Hi: I write a template function is below, that need to remove const topmost if has. How to do this? const int i =3; println(i); void println(A...)(A a) { char[20] numStr = void; foreach(v ; a) { if (is(v.type == byte) || is(v.type == ubyte) ||

how to definition a non-const pointer that point a const var.

2019-08-23 Thread lili via Digitalmars-d-learn
Hi: In C we can definition const int *ncp_to_cv; or int * const cp_to_ncv; How to do this in D.

Re: Is there has an pdf document for Phobos.

2019-09-04 Thread lili via Digitalmars-d-learn
On Wednesday, 4 September 2019 at 04:21:10 UTC, Mike Parker wrote: On Wednesday, 4 September 2019 at 03:07:18 UTC, lili wrote: Hi: For some reason it too slow that some times i visited dlang.org, Can admin make a pdf document for download. Documentation is installed with the compiler.

Re: Is there has an pdf document for Phobos.

2019-09-04 Thread lili via Digitalmars-d-learn
On Wednesday, 4 September 2019 at 04:21:10 UTC, Mike Parker wrote: On Wednesday, 4 September 2019 at 03:07:18 UTC, lili wrote: Hi: For some reason it too slow that some times i visited dlang.org, Can admin make a pdf document for download. Documentation is installed with the compiler.

How to mark a condition is likeyly or unlikey ?

2019-08-07 Thread lili via Digitalmars-d-learn
Hi: In C there has likely unlikely marco used by condition expression。 #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) if (likely(var > 1)) do... How to do this in Dlang?

Why dynamic array is InputRange but static array not.

2019-09-24 Thread lili via Digitalmars-d-learn
Hi: in phobos/std/range/primitives.d has this code ``` static assert( isInputRange!(int[])); static assert( isInputRange!(char[])); static assert(!isInputRange!(char[4])); static assert( isInputRange!(inout(int)[])); ``` but the dynamic array and static array neither not has

what is the mean that call function start with a dot.

2019-09-21 Thread lili via Digitalmars-d-learn
Hi: yesterday I saw some d code, where is an .fn() call syntax, what is it mean.

Is there any writeln like functions without GC?

2019-10-30 Thread lili via Digitalmars-d-learn
Hi: why writeln need GC?

About the in expression, Why can't use with array.

2019-10-24 Thread lili via Digitalmars-d-learn
Hi: In Dlang where is strange design. The in expression can only use to associative array, why array can not use in expression.

Re: About the in expression, Why can't use with array.

2019-10-24 Thread lili via Digitalmars-d-learn
On Thursday, 24 October 2019 at 22:40:31 UTC, Jonathan M Davis wrote: On Thursday, October 24, 2019 7:04:56 AM MDT Paul Backus via Digitalmars-d- learn wrote: On Thursday, 24 October 2019 at 12:58:11 UTC, lili wrote: > Hi: >In Dlang where is strange design. The in expression can > only >

Can not understand this code.

2019-10-25 Thread lili via Digitalmars-d-learn
Hi: What is the alias Min = xxx mean? why need defined a alias Min in Min template? ``` template Min(alias pred, Args...) if (Args.length > 0 && __traits(isTemplate, pred)) { static if (Args.length == 1) { alias Min = Alias!(Args[0]); } else static if (isLess!(pred,

What do you think about About C++20 Concepts?

2019-10-22 Thread lili via Digitalmars-d-learn
Hi: In C++20 Concepts is great idear. but I thinks it is too difficult to write. I like Rust traits simple and elegancy.

Re: About the in expression, Why can't use with array.

2019-10-25 Thread lili via Digitalmars-d-learn
On Friday, 25 October 2019 at 21:06:53 UTC, IGotD- wrote: On Friday, 25 October 2019 at 20:44:18 UTC, Dennis wrote: On Friday, 25 October 2019 at 19:49:05 UTC, Ali Çehreli wrote: I'm still not completely sold on the whole idea though because it's not a clear win. Do others see other

Why Dlang use parsing expression grammar (PEG) parser not BNF?

2019-10-31 Thread lili via Digitalmars-d-learn
Hi: I want implementation Lua on D, I find that a PEG parser https://github.com/PhilippeSigaud/Pegged why do not use BNF parser. Is PEG better than BNF?

How to cross build a RISC-V target betterC code using LDC on x86-64 machine

2021-06-06 Thread lili via Digitalmars-d-learn
I have used to ldc2(1.20.1) on x86-64 laptop with `ldc2 -c -betterC -mtriple=riscv64 betterC.d -v ` but comiple is failed. output: ``` binary/usr/bin/ldc2 version 1.20.1 (DMD v2.090.1, LLVM 10.0.0) config/etc/ldc2.conf (riscv64) 'generic' is not a recognized processor for this

Now can build and run d on RISC-V arch?

2021-06-05 Thread lili via Digitalmars-d-learn
I want learn RISC-V and write a simple kernel on it using d. but can not find any support about RISC-V.

Re: Now can build and run d on RISC-V arch?

2021-06-05 Thread lili via Digitalmars-d-learn
On Sunday, 6 June 2021 at 04:53:08 UTC, Nicholas Wilson wrote: On Sunday, 6 June 2021 at 04:14:20 UTC, lili wrote: I want learn RISC-V and write a simple kernel on it using d. but can not find any support about RISC-V. LDC can compile for riscv 32 and 64 bit.

Is remove safe using foreach

2022-12-12 Thread lili via Digitalmars-d-learn
``` int[string] aa = ["ok":1, "aaa":2, "ccc":3, "ddd":4]; foreach (k ; aa.byKey) { if (k == "aaa") { aa.remove(k); aa["ww"] = 33; } if (k == "ww") { aa.remove(k);

Re: Is remove safe using foreach

2022-12-12 Thread lili via Digitalmars-d-learn
is foreach Syntactic sugar?, like for-range in C++, if it is, compiler how implement

is Dlang support Uniform initialization like c++

2023-06-30 Thread lili via Digitalmars-d-learn
struct Point { int x; int y; this(int x, int y) { this.x =x; this.y=y;} } void addPoint(Point a, Point b) { ... } How too wirte this: addPoint({4,5}, {4,6})