I am currently trying to learn how to program in D. I thought
that I could start by trying some maze generation algorithms. I
have a maze stored as 2D array of structure defined as follow
which keep tracks of wall positions:
~~~
struct s_cell
{
bool north = true;
bool east = true;
boo
On Tuesday, 4 June 2024 at 16:19:39 UTC, Andy Valencia wrote:
On Tuesday, 4 June 2024 at 12:22:23 UTC, Eric P626 wrote:
I tried to find a solution on the internet, but could not find
anything, I stumble a lot on threads about Go or Rust language
even if I specify "d language" in my search.
A
On Wednesday, 5 June 2024 at 10:36:50 UTC, Nick Treleaven wrote:
```d
import std.stdio;
alias s_cell = int;
void main()
{ writeln("Maze generation demo");
s_cell [5][5] maze;
int n;
foreach (i, row; maze)
foreach (j, col; row)
maze[i][j] = n++;
s_cell[][5] slic
I managed to create a random number generator using the following
code:
~~~
auto rng = Random(42);
//
uniform(0,10,rng);
~~~
Now I want to seed the generator using system time. I looked at
Date & time functions/classes and systime functions/classes. The
problem is that they all require a
On Saturday, 8 June 2024 at 21:04:16 UTC, monkyyy wrote:
generate is a very rare function and do novices understand
lamdas?
Yes I know lamdas, but try not to use them.
I am not very picky about the exact source of time, I just want a
different integer every time I run the program. But while l
On Saturday, 8 June 2024 at 18:25:20 UTC, drug007 wrote:
~~~
{
const seed = castFrom!long.to!uint(Clock.currStdTime);
auto rng = Random(seed);
auto result = generate!(() => uniform(0, 10,
rng))().take(7);
// new random numbers sequence every time
res
On Sunday, 9 June 2024 at 13:20:09 UTC, Joseph Rushton Wakeling
wrote:
On Saturday, 8 June 2024 at 16:09:04 UTC, monkyyy wrote:
rng is an optional parameter, `uniform(0,100).writeln;` alone
works; the docs not telling you that is really bad
The docs do tell you that `rng` is an optional parame
On Sunday, 9 June 2024 at 23:31:47 UTC, drug007 wrote:
```d
const seed = cast(uint) Clock.currStdTime;
```
Casting like this looks nice. It fits my type of thinking.
The title of this thread might be weird, but I am currently
reconsidering the language and tools I am using before returning
to production again.
# Objective and projects
Make simple turn based (no animation) video games using Allegro
4, maybe 5, and eventually SDL on multiple platforms: Linu
This is a false dilemma: D has full C compatibility.
From what I understand, D can use C, but C cannot use D? It's
like C++: C++ can call C but C cannot call C++.
50% or more of my code will be put in re-usabled libraries. If I
want people to use those libs, I would need to compile them in C
Any D function marked as extern(C) can be called from C. As
long as you have a C header file defining the functions and the
appropriate C declarations any custom types you have, the C
code will have no idea it's calling into a D library.
Thanks for the example. It clarify things up. The drunti
11 matches
Mail list logo