Re: Octal Prime Numbers (challenge)

2024-06-27 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 25 June 2024 at 06:44:28 UTC, Salih Dincer wrote: I'm not sharing the code for now because it's a challenge. Since we couldn't get a code snippet, I'd like to share some framing code without answers: ```d struct SumPrimes(size_t size) { import std.bigint; auto next = BigInt

SumType extraction

2024-06-27 Thread Josh Holtrop via Digitalmars-d-learn
Hello all. In my application I came across a desire to store an ordered array of handles that could point to one of several different objects, and it seems like the tool I want for that is SumType. I started with something like (simplified of course): ```d class Foo {} class Bar {} alias Ite

12 line program... `main` is a nested function when trying to use redblacktree. Beginner error???

2024-06-27 Thread WhatMeWorry` via Digitalmars-d-learn
import std.container : RedBlackTree; int main() { struct Location { int x; int y; } struct Node{ this(Location loc, uint f) { this.loc = loc; this.f = f; } Location loc; uint f; } auto priorityQueue = new R

Re: 12 line program... `main` is a nested function when trying to use redblacktree. Beginner error???

2024-06-27 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 27, 2024 at 08:56:13PM +, WhatMeWorry` via Digitalmars-d-learn wrote: > import std.container : RedBlackTree; > > int main() > { > > struct Location { > int x; > int y; > } > > struct Node{ > this(Location loc, uint f) { > this.loc

Re: 12 line program... `main` is a nested function when trying to use redblacktree. Beginner error???

2024-06-27 Thread WhatMeWorry via Digitalmars-d-learn
Thanks, that did the trick. Not sure why having the declarations at global scope (or is it module scope in D) would work versus having them at local scope?

Re: 12 line program... `main` is a nested function when trying to use redblacktree. Beginner error???

2024-06-27 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 27, 2024 at 10:14:06PM +, WhatMeWorry via Digitalmars-d-learn wrote: > Thanks, that did the trick. Not sure why having the declarations at > global scope (or is it module scope in D) would work versus having > them at local scope? If you stuck 'static' to the local scope declarati