Library and site D examples
Karmello
Karmello.Kyzer at BasicMail.host
Sun Jan 29 00:03:31 UTC 2023
should automatically include most of the standard library so one
doesn't have to constantly import them just to do basic playing
around with the examples.
For example, I modified an example
import std.array : assocArray;
import std.range : enumerate;
import std.conv, std.algorithm, std.math;
auto aa = iota(1,20).map!(i => round(log(i))).take(10).array;
writeln(to!string(aa));
and had to import the 3rd line. This gets pretty annoying when
playing around with the examples. The most common libs should
automatically be imported and may be dependent on the
library(e.g, if its std.traits maybe import std.meta and others
related).
Also, this example works but in visual stupid the same code gives
me an error:
Error: function `X.Music.map!(Result).map` need `this` to access
member `map`
X.d(22): called from here: `map(iota(1, 100))`
X.d(22): called from here: `take(map(iota(1, 100)), 30u)`
The difference is that I'm trying to generate this sequence at
compile time(it's initializing a struct member). It should be
computable without issue and I'm just replacing hard coded array.
Seems iota isn't being computed at compile time.
struct x
{
static:
auto a = iota(1,1000).map!(i =>
round(log(i))).take(30).array;
}
More information about the Digitalmars-d
mailing list