On Friday, 9 January 2015 at 13:50:29 UTC, eles wrote:
https://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro
From the link: "Let's show Stroustrup what small and readable
program actually is."
Alright, there are a lot a
On Tuesday, 25 November 2014 at 13:56:23 UTC, bearophile wrote:
Right. So the instance data of the struct is more likely
correct when you call its methods.
Thanks. - Well I'd like to see more of these tips. My current
code in D looks like C++ and of course I sure that I'm not
extracting the p
On Monday, 24 November 2014 at 22:50:33 UTC, bearophile wrote:
And the @disable this() assures that a struct is correctly
initialized by the constructor.
In the statement: @disable this()
May I understand that you're "disabling" the "default"
constructor of the struct to use your own construct
On Sunday, 2 November 2014 at 20:49:00 UTC, Kornel wrote:
What learning materials do you recommend ??
http://ddili.org/ders/d.en/
Matheus.
On Tuesday, 28 October 2014 at 16:07:38 UTC, MachineCode wrote:
I'm very surprise. If they either equal or fast sometimes the
compiler did great optizations or it's just a multicore
processor that's helping or what else? the first version (from
your post, the one using ranges) change in each it
On Tuesday, 28 October 2014 at 13:30:05 UTC, Nordlöw wrote:
On Tuesday, 28 October 2014 at 11:51:42 UTC, MattCoder wrote:
I forgot to say that I'm compiling with DMD without any
compiler hints/optimizations.
Try compiling with DMD flag
-release
and perhaps also
-release -noboundschec
On Tuesday, 28 October 2014 at 11:48:37 UTC, MattCoder wrote:
And in my benchmark test, the first version is 3x "slower" than
the second one.
I forgot to say that I'm compiling with DMD without any compiler
hints/optimizations.
Matheus.
Hi,
I don't know if I'm missing something but I did some tests with
the popFront and popBack version:
bool isPalindrome(R)(R range)
if (isBidirectionalRange!(R))
{
while (!range.empty){
if (range.front != range.back) return false;
range.popFront();
On Saturday, 19 April 2014 at 17:12:10 UTC, Ali Çehreli wrote:
On 04/19/2014 09:55 AM, MattCoder wrote:
> On Friday, 18 April 2014 at 20:02:41 UTC, Tim Holzschuh via
> Digitalmars-d-learn wrote:
> void main(){
> int myfilter(int a){
> static int[] b;
That static
On Friday, 18 April 2014 at 20:02:41 UTC, Tim Holzschuh via
Digitalmars-d-learn wrote:
Hi there,
I try to remove all equal elements of an array, thus [2,2] -->
[2].
I thought this maybe would be possible with
std.algorithm.reduce, but at least the way I tried it doesn't
work:
arr.reduce(
On Friday, 28 June 2013 at 19:43:37 UTC, Simen Kjaeraas wrote:
import std.stdio;
import std.typecons : tuple;
auto foo(int x, int y){
writeln(x, y);
return tuple(3, 4);
}
void main(){
foo(foo(1,2).tupleof);
}
Hi Simen,
Thanks for your help too, it worked!
On Friday, 28 June 2013 at 19:39:41 UTC, Ellery Newcomer wrote:
However, they can return std.typecons.Tuple, so you could do
this:
auto foo(int i, int j) {
writeln(i, " ", j);
return tuple(3,4);
}
void main() {
foo(foo(1,2).field);
}
Hi Ellery,
Thanks for your help, it works nic
Hi,
I would like to know if it's possible to pass the return of a
function as argument to another function as below:
import std.stdio;
auto foo(int x, int y){
writeln(x, y);
return 3, 4;
}
void main(){
foo(foo(1,2));
}
I would like to print:
1 2
3 4
PS: I tried retu
On Wednesday, 26 June 2013 at 22:43:05 UTC, David wrote:
Am 26.06.2013 22:51, schrieb Gary Willoughby:
I solved it ;)
http://dpaste.dzfl.pl/5cd56e9d
Yes, but "maybe" the interviewer is waiting just one function,
since the question was: "Design a function f". So I rewrote your
example:
impo
On Saturday, 15 June 2013 at 00:47:01 UTC, bearophile wrote:
You have to verify in the function constraint that the lengths
match.
In fact that was intentional, because sometimes I just want few
items from a tuple not all.
For example:
auto RGB = tuple(255, 125, 50);
Variant r,g;
tupleToVar
Hi,
Sooner I asked about this ([Doubt] Variadic arguments as
reference (Possible?) - -
http://forum.dlang.org/thread/jwujjhjizkovvmbeg...@forum.dlang.org).
In fact my intend was to recreate a feature that I like in
Python, where you can assign variables from a tuple, e.g.:
pos = (10, 20)
x
On Friday, 14 June 2013 at 13:20:26 UTC, Regan Heath wrote:
import std.stdio;
import std.conv;
void sum(double value, double*[] numbers ...){
foreach(ref num; numbers)
*num = *num + value;
}
void main(){
double a = 1, b = 2, c = 3;
sum(10, &a, &b, &c);
Hi,
I want to know if there is a way to pass variadic arguments as
reference? DMD says no!
I wrote the snippet code below, but what I want to do in fact is
assign the sum back to respective variables to use somewhere else.
http://dpaste.dzfl.pl/515edfb8
or
import std.stdio;
import std.con
Hi,
I would like to say thanks to "Adam D. Ruppe" and "Ali Çehreli",
since they answered straight to the point!
Thanks again,
Matheus.
Hi,
I need to check if some value exists in a list (Array). To
achieve that, I'm using Associative Arrays like this:
// Example
void main()
{
int[char] aa = [ '+' : 0, '-' : 1];
char ch = '+';
if(ch in aa)
// doSomething()...
}
But I'm looking for a more simple way like:
if(ch in
On Monday, 13 August 2012 at 08:18:08 UTC, Marco Leise wrote:
Am Mon, 13 Aug 2012 00:53:43 +0200
schrieb "bearophile" :
It looks better. But you every time you use a cast in D you
need to be careful, because they are like a sharp tool with
almost no safeties.
Bye,
bearophile
So true. It ha
On Saturday, 11 August 2012 at 20:38:33 UTC, bearophile wrote:
bioinfornatics:
n this case why not using a while loop ?
It uses less lines of code, and with the for loop you have a
single place where to put the loop variable initialization,
test and increment. This makes the code simpler to
22 matches
Mail list logo