On Wednesday, 27 November 2019 at 14:40:56 UTC, Timon Gehr wrote:
On 27.11.19 11:43, ixid wrote:
On Tuesday, 26 November 2019 at 16:33:06 UTC, Timon Gehr wrote:
import std;
void main(){
int[] x=[1,1,2,3,4,4];
int[][] y=x.chunkBy!((a,b)=>a==b).map!array.array;
writeln(y);
}
This
On Tuesday, 26 November 2019 at 16:33:06 UTC, Timon Gehr wrote:
import std;
void main(){
int[] x=[1,1,2,3,4,4];
int[][] y=x.chunkBy!((a,b)=>a==b).map!array.array;
writeln(y);
}
This stuff is a nightmare for less experienced users like myself,
I wish there were a single function
On Monday, 4 November 2019 at 20:46:41 UTC, H. S. Teoh wrote:
On Mon, Nov 04, 2019 at 07:51:26PM +, Tobias Pankrath via
Digitalmars-d-learn wrote:
Why does the following not work? It works, if I move the
'prop' out of 'foo'.
UFCS is only supported for module-level functions, as far as I
On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote:
On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak
wrote:
If you use gdc or ldc you will get same results as c++, or you
can use C log directly:
import std.stdio;
import std.math : pow;
import core.stdc.math;
void main()
{
On Tuesday, 14 August 2018 at 13:38:16 UTC, Everlast wrote:
etc
Thanks all for the comprehensive responses. I was not clearly
separating CTFE and the compilation of the function in thinking
about it. Much clearer now.
On Tuesday, 14 August 2018 at 09:12:30 UTC, ixid wrote:
This will not compile as it says n is not known at compile
time...
This does work if 'value' is changed to immutable and fun to
accept it. So it still seems like a missed opportunity as enum
shouldn't be able to change either.
This will not compile as it says n is not known at compile time:
auto fun(int n) {
static foreach(i;0..n)
mixin(i.to!string ~ ".writeln;");
return;
}
enum value = 2;
void main() {
fun(value);
}
But making it a template parameter fun(int n)() and
On Wednesday, 11 April 2018 at 14:33:06 UTC, Adam D. Ruppe wrote:
On Wednesday, 11 April 2018 at 14:26:53 UTC, ixid wrote:
Is it possible to infer a template's return type from what
it's assigned to? If not is this a difficult or worthless
feature to add?
Not really. The function call needs
Is it possible to infer a template's return type from what it's
assigned to? If not is this a difficult or worthless feature to
add?
OUT fun(IN, OUT)(IN value) {
return value.to!OUT;
}
void main() {
float a = 5.0;
int b = fun(a);
}
On Tuesday, 6 March 2018 at 14:50:05 UTC, ixid wrote:
On Tuesday, 6 March 2018 at 14:37:27 UTC, Steven Schveighoffer
wrote:
Now, there aren't actually docs for Transposed, but you can
find it if you look at std.range.transposed:
https://dlang.org/phobos/std_range.html#transposed
-Steve
On Tuesday, 6 March 2018 at 14:37:27 UTC, Steven Schveighoffer
wrote:
Now, there aren't actually docs for Transposed, but you can
find it if you look at std.range.transposed:
https://dlang.org/phobos/std_range.html#transposed
-Steve
Thanks, I had found that but that is not an explanation
/opt/compilers/dmd2/include/std/algorithm/iteration.d(663):
Deprecation: function `std.range.Transposed!(string[],
cast(TransverseOptions)0).Transposed.save` is deprecated - This
function is incorrect and will be removed November 2018. See the
docs for more details.
If it's going to say 'See
On Saturday, 24 February 2018 at 20:07:04 UTC, kdevel wrote:
I don't get the point of the deprecation message:
--- intprom.d
import std.stdio;
void main ()
{
short s, t;
t = -s;
}
---
$ dmd intprom.d
intprom.d(6): Deprecation: integral promotion not done for -s,
use
On Wednesday, 21 February 2018 at 14:42:56 UTC, Simen Kjærås
wrote:
On Wednesday, 21 February 2018 at 14:29:38 UTC, ixid wrote:
I do not understand what is happening here, I tried to wrote
what I thought would be the answer. If someone could explain
that would be great. I wrote this code:
On Wednesday, 21 February 2018 at 14:11:10 UTC, ParticlePeter
wrote:
struct Foo(T) {
T bar;
this(S)(S s) {
bar = convert(s);
}
}
auto foo = Foo!int(some_float);
this works because S is deduced as typeof(some_float), but how
would I instantiate the struct without relying on auto
On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole
wrote:
write exists in both, writeln exists only in std.stdio.
Use named imports to pick which write you want.
It does seem a little silly to have a name clash with such a
commonly used function. Would it not be better to rename
On Tuesday, 24 January 2017 at 20:51:49 UTC, Stefan Koch wrote:
On Tuesday, 24 January 2017 at 16:41:12 UTC, ixid wrote:
On Tuesday, 24 January 2017 at 16:27:50 UTC, ixid wrote:
On Tuesday, 24 January 2017 at 15:57:48 UTC, Las wrote:
On Tuesday, 24 January 2017 at 13:11:41 UTC, ixid wrote:
On Tuesday, 24 January 2017 at 16:27:50 UTC, ixid wrote:
On Tuesday, 24 January 2017 at 15:57:48 UTC, Las wrote:
On Tuesday, 24 January 2017 at 13:11:41 UTC, ixid wrote:
This code:
T tFunc(alias F, T)(T n) {
n.F;
return n;
}
Produces this error:
Error: no property 'F' for
On Tuesday, 24 January 2017 at 15:57:48 UTC, Las wrote:
On Tuesday, 24 January 2017 at 13:11:41 UTC, ixid wrote:
This code:
T tFunc(alias F, T)(T n) {
n.F;
return n;
}
Produces this error:
Error: no property 'F' for type 'int[]' (or whatever type I
use).
The alias rules
On Wednesday, 27 July 2016 at 00:52:30 UTC, Gorge Jingale wrote:
So, you can see D as a sort of dried up waste land desert with
a few nice palm trees growing here and there and a few
scorpions. C++, say, is a very lush forest with many tree
dwelling monkeys. Which environment would you rather
On Sunday, 29 May 2016 at 07:18:10 UTC, Jonathan M Davis wrote:
And the fact that allowing free functions to overload operators
via UFCS sends us into that territory just highlights the fact
that they're a horrible idea.
- Jonathan M Davis
Do you have any examples of UFCS doing bad things?
On Sunday, 22 May 2016 at 12:55:47 UTC, Guillaume Piolat wrote:
On Sunday, 22 May 2016 at 12:13:07 UTC, ixid wrote:
What is the best OpenGL tutorial with D to use? I've tried to
use d-gamedev-intro and opengl-tutorials and seem to get
errors, files that are no longer included are needed (dgl)?
What is the best OpenGL tutorial with D to use? I've tried to use
d-gamedev-intro and opengl-tutorials and seem to get errors,
files that are no longer included are needed (dgl)? and
deprecation messages.
On Thursday, 31 March 2016 at 13:48:27 UTC, Adam D. Ruppe wrote:
It is trying to look up a name i in global scope, and calling
writeln on it.
This is why the .name syntax exists: so you can bypass local
variables with the same name when trying to access a global.
It would compile if you put
What is going on with UFCS and foreach?
foreach(i;0..5).writeln;
This prints five line breaks.
foreach(i;0..5).i.writeln;
This will not compile.
foreach(i;0..5).writeln(i);
This writes out 1 to 4 on separate lines. Is this supposed to
work? I thought a.b would be rewritten to b(a) with
On Tuesday, 23 February 2016 at 14:07:22 UTC, Marc Schütz wrote:
On Tuesday, 23 February 2016 at 11:10:40 UTC, ixid wrote:
We really need to standard algorithms to be fast and perhaps
have separate ones for perfect technical accuracy.
While I agree with most of what you're saying, I don't
On Monday, 22 February 2016 at 15:43:23 UTC, dextorious wrote:
I do have to wonder, however, about the default settings of dub
in this case. Having gone through its documentation, I might
still not have guessed to try the compiler options you
provided, thereby losing out on a 2-3x performance
On Thursday, 4 February 2016 at 22:13:36 UTC, Ola Fosheim Grøstad
wrote:
Well, it is probably not the best point in time to have
absolute beginners use D anyway.
That is a ridiculous thing to say and a great way of ensuring a
language dies. Good starting resources help everyone.
On Thursday, 4 February 2016 at 11:04:23 UTC, cym13 wrote:
On Thursday, 4 February 2016 at 10:18:35 UTC, ixid wrote:
Do you think your knowledge and experience is a good model for
how a new user who hasn't done much if any programming before
would approach this?
A design choice had to be
On Thursday, 4 February 2016 at 10:05:15 UTC, Jonathan M Davis
wrote:
I would normally expect someone to do that with writefln, which
would be cleaner. e.g.
writefln("%s %s %s %s", a, b, c, d);
Personally, I've never felt the need for a function like you're
describing.
- Jonathan M Davis
On Thursday, 4 February 2016 at 13:46:46 UTC, Dejan Lekic wrote:
On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote:
It would be nice to have a simple writeln that adds spaces
automatically like Python's 'print' in std.stdio, perhaps
called print.
There are many implementations of
On Thursday, 4 February 2016 at 17:34:33 UTC, Artur Skawina wrote:
On 02/04/16 16:32, Artur Skawina wrote:
but that seems too expensive, when the use is just in toy
programs and debugging.
I hadn't really considered the relative cost-benefit, it's just a
habit to try to hardcode things at
It would be nice to have a simple writeln that adds spaces
automatically like Python's 'print' in std.stdio, perhaps called
print.
On Thursday, 4 February 2016 at 00:30:03 UTC, cym13 wrote:
On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote:
It would be nice to have a simple writeln that adds spaces
automatically like Python's 'print' in std.stdio, perhaps
called print.
Sounds way too redundant to me.
Normally
This is an idle thought hence putting it on the Learn-level
forum. An idea struck me for foreach to make working with more
complicated data types or heavily nested data easier.
uint[][] a = [[1,2,3],[4,5,6]];
foreach(uint[] b; a)
b.writeln;
At
On Thursday, 28 January 2016 at 15:38:20 UTC, Ali Çehreli wrote:
On 01/28/2016 05:33 AM, ixid wrote:
> This is an idle thought hence putting it on the Learn-level
forum. An
> idea struck me for foreach to make working with more
complicated data
> types or heavily nested data easier.
>
>
>
On Monday, 25 January 2016 at 08:31:14 UTC, abad wrote:
On Monday, 25 January 2016 at 02:27:57 UTC, Solomon E wrote:
On Saturday, 23 January 2016 at 07:57:55 UTC, Ali Çehreli
Ruby's Array class includes this sort method for flattening and
for me it was surprisingly useful, for instance when it
On Thursday, 5 November 2015 at 05:41:46 UTC, Jonathan M Davis
wrote:
On Wednesday, November 04, 2015 21:22:02 ixid via
Digitalmars-d-learn wrote:
On Wednesday, 4 November 2015 at 19:09:42 UTC, Maxim Fomin
wrote:
> On Wednesday, 4 November 2015 at 14:27:49 UTC, ixid wr
This may have been overlooked in my other thread so I wanted to
ask again:
This seems very inconsistent, does a += b not lower to a = a + b?
I guess not based on the below:
ushort a = ushort.max, b = ushort.max;
a += b; // Compiles fine
a = a + b; // Error: cannot implicitly
On Wednesday, 4 November 2015 at 19:09:42 UTC, Maxim Fomin wrote:
On Wednesday, 4 November 2015 at 14:27:49 UTC, ixid wrote:
Is there an elegant way of avoiding implicit conversion to int
when you're using shorter types?
Only with library solution. Implicit conversions are built into
On Wednesday, 4 November 2015 at 14:27:49 UTC, ixid wrote:
Is there an elegant way of avoiding implicit conversion to int
when you're using shorter types?
Also does this not seem inconsistent:
ushort a = ushort.max, b = ushort.max;
a += b; // Compiles fine
a = a + b; // Error:
Is there an elegant way of avoiding implicit conversion to int
when you're using shorter types?
On Tuesday, 3 November 2015 at 15:06:00 UTC, Namal wrote:
Can you help me out please. Thx.
reduce!((x, y) => x + !y)(0, arr).writeln;
This would probably be the preferred way, that uses a lambda
function (x, y) => x + !y which adds the inverse of the next
array value (y) to the total so far
On Wednesday, 4 November 2015 at 17:26:04 UTC, Daniel Kozak wrote:
V Wed, 04 Nov 2015 14:27:45 +
ixid via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
napsáno:
Is there an elegant way of avoiding implicit conversion to int
when you're using shorter types?
http://dla
On Saturday, 10 October 2015 at 16:19:53 UTC, Nordlöw wrote:
Is there an algorithm somewhere in Phobos which performs when
possible a replacement/substitution based on a variadic
definition of replacements using hash-table search similar to
string replaceWhole(string a)
{
switch (x)
{
Does sort have to be eager or would it be possible to have a lazy
version? It's messy to always have to use array and leap in and
out of lazy operations within a UFCS chain. Surely as many
functions as possible should be optionally lazy.
On Friday, 11 September 2015 at 11:08:29 UTC, Ola Fosheim Grøstad
wrote:
On Friday, 11 September 2015 at 10:41:16 UTC, ixid wrote:
Does sort have to be eager or would it be possible to have a
lazy version? It's messy to always have to use array and leap
in and out of lazy operations within a
On Tuesday, 18 August 2015 at 16:02:42 UTC, cym13 wrote:
On Tuesday, 18 August 2015 at 15:51:55 UTC, ixid wrote:
Though sugar seems to be somewhat looked down upon I thought
I'd suggest this- having seen the cartesianProduct function
from std.algorithm in another thread I thought it would be
Though sugar seems to be somewhat looked down upon I thought I'd
suggest this- having seen the cartesianProduct function from
std.algorithm in another thread I thought it would be an
excellent piece of sugar in the language. It's not an earth
shattering change but it makes something very
This seems like a reasonable use but errors, obviously I can do
it in many other ways:
ulong[] result = iota(1UL, 10UL).array;
Error: static assert Argument types in (ulong) are not all
convertible to size_t:
(ulong) C:\D\dmd2\src\phobos\std\array.d 516
And while I'm here why do
On Sunday, 9 August 2015 at 20:33:10 UTC, anonymous wrote:
On Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote:
Yup, bug. Please file an issue at http://issues.dlang.org/.
It seems like bearophile beat me to it. Good to see he's still
alive.
int[] a = [1,1,1,1];
int[] b = [1,1,1,1];
int[] c;
c[] = a[] - b[];
c.writeln;
This outputs []. This feels wrong, it feels like something that
should have exploded or set the length to 4. If the lengths of a
and b are mismatched it throws an exception.
On Thursday, 22 January 2015 at 16:41:49 UTC, Russel Winder wrote:
Playing with factorial implementations, as you do. I had a D
implementation using ulong. Not sensible obviously since
overflow is a
bit of a problem. But the code worked, as did the tests. Now
converting
to BigInt and…
The
On Tuesday, 6 January 2015 at 20:49:34 UTC, Rene Zwanenburg wrote:
On Tuesday, 6 January 2015 at 20:26:25 UTC, ixid wrote:
Dmd latest non-beta, with the latest VisualD. Debug build.
Debug build and no additional or non default settings.
Hmm..
Did you verify that the D installation directory
On Tuesday, 6 January 2015 at 18:37:25 UTC, Rene Zwanenburg wrote:
On Monday, 5 January 2015 at 15:59:17 UTC, ixid wrote:
On Friday, 31 August 2012 at 22:52:13 UTC, Jonathan M Davis
wrote:
On Saturday, September 01, 2012 00:40:25 deed wrote:
import std.random
void main() {}
---
results
On Friday, 31 August 2012 at 22:52:13 UTC, Jonathan M Davis wrote:
On Saturday, September 01, 2012 00:40:25 deed wrote:
import std.random
void main() {}
---
results in:
Error 42: Symbol Undefined
_D4core6memory2GC6qallocFkkZS4core6memory8BLkInfo_
Error 42: Symbol Undefined
Why don't templates take a type from the default argument if
nothing else is supplied? It would be useful to be able to use an
enum to set a default.
enum MAX = 1_000;
auto sieve(T)(T max = MAX) {
import std.bitmanip : BitArray;
BitArray n;
n.length = max;
T[]
T shadow(T = int)(T a) {
alias T = string;
T b = hi;
T c = 1; // Error
writeln(typeof(a).stringof); // int
writeln(typeof(b).stringof); // string
return a;
}
Are there uses for this shadowing of type names? It seems a
little dangerous, for
58 matches
Mail list logo