On Thursday, 17 December 2015 at 14:09:57 UTC, Suliman wrote:
Next code produce error:
foreach(i, line;fileContent.byLine)
Error: cannot infer argument types, expected 1 argument, not 2
Why it's do not work?
Because byLine doesn't return an array, use std.range.enumerate :
On Sunday, 13 December 2015 at 03:08:33 UTC, Namal wrote:
On Saturday, 12 December 2015 at 23:50:55 UTC, Xinok wrote:
[...]
I tried this, it compiles, but crashes when I try to run it:
object.Exception@/usr/include/dmd/phobos/std/algorithm/iteration.d(2481):
Enforcement failed
On Sunday, 13 December 2015 at 20:29:47 UTC, Pederator wrote:
Hi. Does anybody who is familair with D consider to make a
comprehensive D programming video tutorial / training / course?
This could be encouraging and helpful for people to start with
D. It could also help in promoting D
On Sunday, 13 December 2015 at 00:36:29 UTC, Namal wrote:
On Sunday, 13 December 2015 at 00:02:11 UTC, cym13 wrote:
Now that I think about it, it's true that it would make no
sense whatsoever to return a range as reduce is typically used
to return a single value... At least it makes perfect
On Saturday, 12 December 2015 at 23:10:21 UTC, Namal wrote:
Hello guys,
I am still uncertain how to do it right when it comes to lambda
functions.
If you are looking for the functionnal way I'd advise that you
start by
looking up three functions in a language-agnostic way: filter,
map and
On Saturday, 12 December 2015 at 23:50:55 UTC, Xinok wrote:
On Saturday, 12 December 2015 at 23:36:43 UTC, cym13 wrote:
...
So, in your example:
int product(const ref int[] arr) {
import std.array: array;
import std.algorithm: reduce;
arr = arr.reduce!((p, i) => p*i).array;
}
On Saturday, 12 December 2015 at 23:59:01 UTC, cym13 wrote:
On Saturday, 12 December 2015 at 23:50:55 UTC, Xinok wrote:
On Saturday, 12 December 2015 at 23:36:43 UTC, cym13 wrote:
...
So, in your example:
int product(const ref int[] arr) {
import std.array: array;
import
On Wednesday, 9 December 2015 at 13:23:00 UTC, Tim K. wrote:
On Wednesday, 9 December 2015 at 13:13:36 UTC, BBaz wrote:
Is there a convenience function that allows me to remove an/all
object(s) with a certain value from an array or do I need to
write one myself?
Here are some elements of
On Sunday, 6 December 2015 at 14:41:01 UTC, Márcio Martins wrote:
I am writing a generic numerical array struct, and I can't find
a way to do element-wise comparison operators.
What I had envisioned was something like the following,
assuming a, b, c and m are array-like, and all operations
On Sunday, 6 December 2015 at 12:23:05 UTC, Tim K. wrote:
Hi! I have the following code:
int main(string[] argv)
{
import std.algorithm: sum;
import std.stdio: writeln;
uint[3] a1 = [1, 2, 3];
uint[] a2;
for (int i = 1; i <= 3; ++i)
On Wednesday, 25 November 2015 at 20:24:25 UTC, user-6431 wrote:
I know that AA items order does not follow the additions but is
the order deterministic ?
For example for a given set of items, will they always be
ordered in the same way ? (I mean whatever is the way I append
them to the AA).
On Wednesday, 25 November 2015 at 20:24:25 UTC, user-6431 wrote:
I know that AA items order does not follow the additions but is
the order deterministic ?
For example for a given set of items, will they always be
ordered in the same way ? (I mean whatever is the way I append
them to the AA).
On Tuesday, 24 November 2015 at 23:22:24 UTC, Joseph Rushton
Wakeling wrote:
On Tuesday, 24 November 2015 at 23:14:14 UTC, Joseph Rushton
Wakeling wrote:
I'm considering creating some D bindings for a C library.
I should probably clarify that I know what to do assuming I
have to write all
On Wednesday, 11 November 2015 at 16:02:07 UTC, H. S. Teoh wrote:
If performance is a problem, my first reaction would be to try
GDC or LDC. While there have been recent improvements in DMD
code generation quality, it still has a ways to go to catch
with GDC/LDC's optimizer.
T
My
On Tuesday, 10 November 2015 at 13:09:09 UTC, Fyodor Ustinov
wrote:
Hi!
Is it possible when using the "-release" indicate that this one
in/out/invariant/assert should not to be disabled?
WBR,
Fyodor.
I don't quite get why you'd like to use -release if you are
paranoid enough to be
On Wednesday, 11 November 2015 at 02:38:19 UTC, puming wrote:
Hi,
If I have multiple ranges, say:
auto a = [1, 2, 3];
auto b = ["a", "b", "c"];
auto c = ["x", "y", "z"];
I'd like a composition range that enumerate all combinations of
these ranges,
having the same effect as a nested foreach
On Thursday, 5 November 2015 at 13:08:20 UTC, Adam D. Ruppe wrote:
On Thursday, 5 November 2015 at 10:04:02 UTC, Andrea Fontana
wrote:
Anyway: are duplicated keys on declaration allowed?
They shouldn't be...
Why? I'll admit it is something I've never even thought of using,
but every
On Friday, 6 November 2015 at 14:28:53 UTC, cym13 wrote:
auto aa = ["a":10, "b", 42, "a":20];
This should readauto aa = ["a":10, "b":42, "a":20]; of
course.
On Friday, 6 November 2015 at 10:00:23 UTC, Namal wrote:
On Thursday, 5 November 2015 at 17:40:12 UTC, bearophile wrote:
Namal:
Hello I am trying to convert BigInt to string like that while
trying to sort it:
void main() {
import std.stdio, std.algorithm, std.conv, std.bigint,
On Wednesday, 14 October 2015 at 14:42:31 UTC, Namal wrote:
Hello,
I don't remember exactly but I think when I first saw D code
there was tree datatype implemented without pointers. Is it
possible to make a tree struct without pointers?
If it is a binary tree, sure: just put your elements
On Wednesday, 14 October 2015 at 18:07:25 UTC, Meta wrote:
The answer is more or less no, unless you sort of fake it like
in cym13's example. A tree is not possible without pointers due
to its recursive nature. Even if it looks like the
implementation doesn't use pointers, they're just hidden
On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote:
Why is the following code not pure:
float x = 3.14;
import std.conv : to;
auto y = x.to!string;
???
Is there a reason for it not being pure? If not, this is a
serious problem as this is such a fundamental function.
On Monday, 21 September 2015 at 22:24:22 UTC, French Football
wrote:
On Monday, 21 September 2015 at 19:23:38 UTC, cym13 wrote:
On Monday, 21 September 2015 at 16:32:25 UTC, French Football
wrote:
[...]
I had to look into phobos sources
(/usr/include/dlang/dmd/std/containers/dlist.d) to
On Monday, 21 September 2015 at 15:38:40 UTC, French Football
wrote:
Going through a book on coding in D,
http://ddili.org/ders/d.en/foreach.html , I find the following
very useful feature:
When two names are specified in the names section [with a plain
array], they represent an automatic
On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote:
import std.range;
void main() {
int[6] a = [1, 2, 3, 4, 5, 6];
pragma(msg, isInputRange!(typeof(a)));
pragma(msg, isForwardRange!(typeof(a)));
pragma(msg, isRandomAccessRange!(typeof(a)));
}
$ dmd -run test.d
On Monday, 21 September 2015 at 16:32:25 UTC, French Football
wrote:
On Monday, 21 September 2015 at 15:54:06 UTC, Justin Whear
wrote:
On Monday, 21 September 2015 at 15:58:12 UTC, cym13 wrote:
Thankyou! .enumerate lets me iterate over a container with a
counter.
--Related tangential
On Wednesday, 16 September 2015 at 12:55:13 UTC, smadus wrote:
Hello
Searching after hours, i give up and here is the question. ;)
I will make a programm, this searching all txt files on the
system or the path from user and searching a user tiped term in
this file.
On Monday, 14 September 2015 at 14:17:51 UTC, Laeeth Isharc wrote:
chain doesn't seem to compile if I try and chain a chain of two
strings and another string.
what should I use instead?
Laeeth.
std.algorithm.iteration.joiner?
On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar
wrote:
On Tuesday, 8 September 2015 at 18:45:33 UTC, Jonathan M Davis
wrote:
[...]
@Jonathan, @cym13 and @Meta
It's reasonable to use `auto`. However there are times when
you need to pass the `auto` value to another function and
On Wednesday, 9 September 2015 at 11:30:26 UTC, Bahman Movaqar
wrote:
For the lame example I gave, something similar occurred to me
at first; but then I thought 4 `filter`s (assuming `all` is
simply a `filter`) might be non-idiomatic as it might incur
some performance penalty.
As those are
On Wednesday, 9 September 2015 at 20:34:03 UTC, Ola Fosheim
Grøstad wrote:
On Wednesday, 9 September 2015 at 20:17:44 UTC, cym13 wrote:
This is subtly missing the main question: isn't C++-like
memory management of D classes possible with Unique,
RefCounted and Scoped? I understand the
On Wednesday, 9 September 2015 at 20:05:06 UTC, ponce wrote:
C++ only has a D struct equivalent so all destructors are
called deterministically. It's the addition of classes that
create the problems in D.
C++ can also throw by value, something that D can't really do.
C++ objects can be:
-
Hi,
I know C++ and D without being a C++ or D guru (I know way more
about D though). When talking about memory management the problem
of RAII is often mentioned along with the fact that classes use
the GC. I know well the difference between structs and classes
and don't want to talk about
On Tuesday, 8 September 2015 at 09:48:35 UTC, Bahman Movaqar
wrote:
From what I can gather the output of `std.algorithm.iteration :
filter` is a `FilterResult` type.
I need a bit of help dealing with this type:
1. Why this type is there in the first place instead of
simply using the type of
On Tuesday, 8 September 2015 at 11:08:59 UTC, Bahman Movaqar
wrote:
However, I have made this a strict practice of mine to specify
the full signature of my public API. I suppose, if I want to
be pedantic, I have to realise the lazy value first and pass
the resulting array out. Is this
On Monday, 7 September 2015 at 09:06:05 UTC, Nordlöw wrote:
Is there a range in Phobos for accessing all unordered
combinations of a range as:
foreach (const i, const a; r)
{
for (auto j = i + 1; j < r.length; ++j)
{
const b = r[j];
// Use a and b
}
}
excluding
On Sunday, 6 September 2015 at 21:01:09 UTC, Namal wrote:
On Sunday, 6 September 2015 at 20:39:27 UTC, deed wrote:
On Sunday, 6 September 2015 at 17:57:49 UTC, Namal wrote:
Yeah, I just checked, it is 2.066, how can I install the new
version on ubuntu with sudo apt-get?
sudo apt-get
On Sunday, 6 September 2015 at 21:18:28 UTC, Namal wrote:
That should be it though... Could you try this minimal
complete test?
import std.stdio;
import std.algorithm;
void main(string[] args) {
int[] arr = [1, 2, 4, 2, 3, 4, 1];
arr.sort.uniq.writeln;
}
// [1, 2, 3, 4]
yes, it
On Saturday, 5 September 2015 at 11:12:17 UTC, Sebastiaan Koppe
wrote:
```
import std.algorithm;
char[1024] buffer;
buffer.find("LOCATION: "); // get error about how all the
different versions of find don't match
```
```
import std.algorithm;
char[1024] buffer;
buffer[0..$].find("LOCATION:
On Wednesday, 2 September 2015 at 15:04:10 UTC, cym13 wrote:
On Wednesday, 2 September 2015 at 13:46:54 UTC, Namal wrote:
Thx, cym. I have a question about a D strings though. In c++ I
would just reuse the string buffer with the "=" how can I
clear the string after i store a line in the buffer
On Wednesday, 2 September 2015 at 13:01:31 UTC, Namal wrote:
Hello,
I want to read a file line by line and store each line in a
string. I found this example with byLine and ranges. First of
all, do I need the range lib at all to do this and if so what
is the range of the end of the file?
On Wednesday, 2 September 2015 at 13:46:54 UTC, Namal wrote:
Thx, cym. I have a question about a D strings though. In c++ I
would just reuse the string buffer with the "=" how can I clear
the string after i store a line in the buffer and do something
with it. I also tried to append a line to
On Tuesday, 1 September 2015 at 14:48:55 UTC, Stephen wrote:
So I've been trying to install Dlang, VisualD, and Dub for the
past day with little luck. I have DMD 1 and 2, and VisualD
installed, but I can't get Dub working.
Are you on linux or windows or...? Please, give a bit of context.
On Monday, 31 August 2015 at 22:21:20 UTC, Taylor Hillegeist
wrote:
I thought that perhaps spawing a process would work but
execute("PATH TO HTML
FILE",null,Config.none,size_t.max,dirName(exepath));
Didn't seem to work? any ideas?
Use curl:
void main(string[] args) {
import std.stdio,
On Monday, 31 August 2015 at 11:06:40 UTC, drug wrote:
On 31.08.2015 13:57, Andrea Fontana wrote:
Just create a function that return a string with those three
lines and
mixin it!
Like:
import std.stdio;
string toMix( string a, string b, string c)
{
return `string a = "` ~ a ~ `";` ~
On Monday, 31 August 2015 at 13:17:30 UTC, cym13 wrote:
On Monday, 31 August 2015 at 13:00:49 UTC, Namal wrote:
Hey guys, since I am learning D arrays here, can you tell me
the best way to remove an element at the end of an array or at
some index i?
import std.algorithm;
T[] arr;
arr =
On Monday, 31 August 2015 at 01:01:32 UTC, mzf wrote:
On Saturday, 29 August 2015 at 12:56:08 UTC, cym13 wrote:
Hi,
Let's say I have a simple binary file whose structure is
well-known. Here is
an example which stores points:
struct Point {
long x;
long y;
long z;
}
struct
On Monday, 31 August 2015 at 13:00:49 UTC, Namal wrote:
Hey guys, since I am learning D arrays here, can you tell me
the best way to remove an element at the end of an array or at
some index i?
import std.algorithm;
T[] arr;
arr = arr.remove(index);
On Monday, 31 August 2015 at 12:43:25 UTC, drug wrote:
On 31.08.2015 15:28, Andrea Fontana wrote:
On Monday, 31 August 2015 at 11:06:40 UTC, drug wrote:
On 31.08.2015 13:57, Andrea Fontana wrote:
Just create a function that return a string with those three
lines and
mixin it!
Like:
On Sunday, 30 August 2015 at 09:55:02 UTC, Dominikus Dittes
Scherkl wrote:
And the constraints you need not read - unless you want to
understand why your call to the function failed. C++ is just
lacking without them. Having them avoids that you always have
to handle ridiculous input within
Hi,
Let's say I have a simple binary file whose structure is
well-known. Here is
an example which stores points:
struct Point {
long x;
long y;
long z;
}
struct BinFile {
uintmagicNumber; // Some identifier
ulong pointsNumber;
Point[] points; // Array of
On Saturday, 29 August 2015 at 13:56:10 UTC, drug wrote:
Try, for example, MessagePack
https://github.com/msgpack/msgpack-d.git
Thanks, but it isn't answering the question at all. I'm not
looking for a
serialization method, I'm looking for the best way to read a
binary file.
On Saturday, 29 August 2015 at 14:52:51 UTC, drug wrote:
29.08.2015 17:17, cym13 пишет:
On Saturday, 29 August 2015 at 13:56:10 UTC, drug wrote:
Try, for example, MessagePack
https://github.com/msgpack/msgpack-d.git
Thanks, but it isn't answering the question at all. I'm not
looking for a
On Saturday, 29 August 2015 at 16:47:23 UTC, Laeeth Isharc wrote:
Align(1) ?
That should do it, thanks :)
On Monday, 24 August 2015 at 17:59:00 UTC, Michal Minich wrote:
Ok. What about this: there exactly the same 3 primitives as in
D range, but popFront is requred to be called first, before
calling front, or empty properties. Why current approach
against this?
Wouldn't that mean a null
On Tuesday, 25 August 2015 at 22:35:57 UTC, Jim Hewes wrote:
Although C++ can be ugly, one reason I keep going back to it
rather then commit more time to reference-based languages like
C# is because I like deterministic destruction so much. My
question is whether D can REALLY handle this or
On Friday, 21 August 2015 at 22:39:29 UTC, Nick Sabalausky wrote:
Not at a pc, so can't test right now, but does Appender work at
compile time? If not, does ~= still blow up CTFE memory usage
like it used to? Any other best practice / trick for building
strings in CTFE?
I did two
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 an
excellent piece of sugar in the language. It's not an
On Sunday, 16 August 2015 at 11:53:42 UTC, FreeSlave wrote:
Let's say I want to map some range using some context.
The obvious way is to do:
uint[3] arr = [1,2,3];
uint context = 2;
auto r = arr[].map!(delegate(value) { return value * context;
});
The problem is that this allocates delegate,
On Sunday, 16 August 2015 at 11:53:42 UTC, FreeSlave wrote:
Let's say I want to map some range using some context.
The obvious way is to do:
uint[3] arr = [1,2,3];
uint context = 2;
auto r = arr[].map!(delegate(value) { return value * context;
});
To me the obvious way is to use a lambda,
On Sunday, 16 August 2015 at 22:22:07 UTC, Ali Çehreli wrote:
// HERE:
// Error: function deneme.func @nogc function allocates
//a closure with the GC
@nogc auto func(uint[] arr, DelegateRef d)
{
return arr.map!(a = d.d(a));
}
Aren't you making another delegate in the map by using
On Saturday, 15 August 2015 at 11:25:20 UTC, vladde wrote:
I made a PR to phobos where I modified `std.format.format`.
https://github.com/D-Programming-Language/phobos/pull/3528
However the auto builder fails, with the error message:
runnable/test23.d(1219): Error: cannot implicitly convert
On Saturday, 15 August 2015 at 11:34:01 UTC, cym13 wrote:
On Saturday, 15 August 2015 at 11:25:20 UTC, vladde wrote:
I made a PR to phobos where I modified `std.format.format`.
https://github.com/D-Programming-Language/phobos/pull/3528
However the auto builder fails, with the error message:
On Tuesday, 11 August 2015 at 19:56:02 UTC, Suliman wrote:
The code look very trivial, but I am getting infinity loop like:
2014-Aug-02
2014-Aug-02
2014-Aug-02
...
2014-Aug-02
Date startDate = Date.fromISOExtString(2014-08-01);
Date currentDate = to!(Date)(Clock.currTime()-1.days);
On Sunday, 9 August 2015 at 13:22:02 UTC, Reflexive wrote:
Hi
I have seen that it is possible to remove an element from a
associative array, but dont find any reference, including in
D's specification, about any element removing in dynamic array.
I can use loops for that, but isnt any way to
Hi,
I just read
https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ which describes how super works in python (tl;dr: it's completely different from C++, java or D's super but super cool to deal with multiple inheritance).
For example, for the following inheritance tree:
Forget it, I just remembered that we only do single inheritance,
and I don't think the same problem occurs with interfaces.
For reference, as the diagram was unreadable, I'll describe it
here:
class Adam ;
class Eve ;
class Abel:Adam,Eve ;
class Cain:Adam,Eve ;
class David:Abel,Cain ;
On Sunday, 2 August 2015 at 19:04:15 UTC, Malte Kießling wrote:
Hello,
I am trying to use rdmd to create shared object files.
The command that I am using is
rdmd --build-only -shared -fPIC -defaultlib= foo.d
This creates a file called foo - wich is not exactly what I
expectd.
However
dmd
On Sunday, 2 August 2015 at 09:24:12 UTC, Matt wrote:
I was planning to use a dynamic array of indices to represent a
deck of cards, and was wondering if there was any easy way to
shuffle the arrays contents? I checked the library docs, but
came to the conclusion that sorting arrays is a much
On Thursday, 23 July 2015 at 11:15:46 UTC, Enjoys Math wrote:
1. Is the best way to hash a uint[] slice
2. How do you do it?
IIRC, std.digest functions take ubyte[] as input, so to hash a
uint[] I would do the following:
void main(string[] args)
{
import std.conv;
On Sunday, 28 June 2015 at 05:04:48 UTC, DlangLearner wrote:
I will convert a Java program into D. The original Java code is
based on the class RandomeAccessFile which essentially defines
a set of methods for read/write Int/Long/Float/String etc. The
module std.stream seems to be a good fit
Not sure what kind of meat you mean, but I really don't see
much meat in ranges. Of course, this is 10 times better and
easier to use than STL iterators C++. For me the most important
feature D are mixins, which I, unfortunately, rarely use. I'm
waiting for new features from D: for new
(just noticed a weird typo trend with know/now
%s/know/now/g)
EDIT: mis-formatted previous snippet
import std.algorithm, std.stdio, std.range, std.conv;
void main()
{
stdin
.byLine
.filter!(s = !s.empty s.front != '#’) // Filter with
this lambda function
.map!(s = s.to!double) // Map the strings to doubles
.array //
On Monday, 6 April 2015 at 18:00:46 UTC, Szymon Gatner wrote:
Why is that? The use case is to provide a set of convenience
extension methods to a basic interface. Say, given:
This is not the only use case, another (maybe even more common)
use is to allow pipeline programming.
Example from
Hello,
I see a lot of functions and other stuff with a '!' in the name
such as 'bitfields!' or 'ctRegex!'. What does it mean exactly? In
scheme, we use such a convention to warn that a function is not
pure, but I don't see the point of using it that way in D as
there are other way to express it.
201 - 276 of 276 matches
Mail list logo