On 9/04/2015 9:49 p.m., wobbles wrote:
So, I'm writing a poker AI bot. The idea was to generate a lookup table
of all the poker hands using CTFE so runtime can be as quick as possible
(as the bot has a very small amount of time to act).
There are a LOT of calculations though, many millions of
Don't use string == null, it is true for empty strings since null
and an empty string are almost interchangable.
You can try if(string is null) - is instead of ==. Though usually
in D, I just if(string.length == 0) and treat empty and null the
same way.
On Thursday, 9 April 2015 at 11:07:05 UTC, Rikki Cattermole wrote:
Sure when:
import std.traits : ReturnType;
import std.stdio : writeln;
static assert(is(ReturnType!writeln == int));
Thanks.
On Thursday, 9 April 2015 at 11:09:43 UTC, John Colvin wrote:
Yes, because writeln returns nothing,
On Thursday, 9 April 2015 at 11:07:05 UTC, Rikki Cattermole wrote:
On 9/04/2015 11:03 p.m., Dennis Ritchie wrote:
Hi,
Is it allowed in D similar designs?
void main() {
import std.stdio;
return writeln(Hello, world!);
}
Sure when:
import std.traits : ReturnType;
import std.stdio :
So, I'm writing a poker AI bot. The idea was to generate a lookup
table of all the poker hands using CTFE so runtime can be as
quick as possible (as the bot has a very small amount of time to
act).
There are a LOT of calculations though, many millions of
combinations.
During complation,
On Thursday, 9 April 2015 at 11:45:31 UTC, tcak wrote:
I have written a function as follows:
public bool setCookie(
string name,
string value,
long maxAgeInSeconds = long.min,
string expiresOnGMTDate=null,
string path=null,
string domain=null,
On 9/04/2015 11:22 p.m., John Colvin wrote:
On Thursday, 9 April 2015 at 11:07:05 UTC, Rikki Cattermole wrote:
On 9/04/2015 11:03 p.m., Dennis Ritchie wrote:
Hi,
Is it allowed in D similar designs?
void main() {
import std.stdio;
return writeln(Hello, world!);
}
Sure when:
import
Sorry, i meant it gives b == fooo\\nbar
I'm writing an interpreter and it should dump original string
from memory.
Also i wonder if there's a function to convert aaa\\nbb to
aaa\nbb (i.e. to unescape)
On Thursday, 9 April 2015 at 05:34:09 UTC, anonymous wrote:
On Wednesday, 8 April 2015 at 22:53:39 UTC, ddos wrote:
why not just make it callable without the alias?
It's to prevent hijacking: http://dlang.org/hijack.html
thx for the article!
On Thursday, 9 April 2015 at 10:04:09 UTC, John Colvin wrote:
On Thursday, 9 April 2015 at 09:49:39 UTC, wobbles wrote:
Another possibilty I was looking at was to write a tool that
will spit out all combinations at runtime, and then import
these back into the bot at compile time to build a
On Thursday, 9 April 2015 at 14:49:24 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:42:33 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:30:07 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:16:00
On Thursday, 9 April 2015 at 09:49:39 UTC, wobbles wrote:
Another possibilty I was looking at was to write a tool that
will spit out all combinations at runtime, and then import
these back into the bot at compile time to build a lookup table
that way.
Thanks!
This is definitely a better
On Thursday, 9 April 2015 at 14:42:33 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:30:07 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote:
By the way, I am using DMD64 D Compiler v2.067.0
On Thursday, 9 April 2015 at 13:09:57 UTC, Temtaime wrote:
Hi ! I wonder how to escape a string in phobos ?
For example
auto a = [ fooo\nbar ];
auto b = format(%(%s%), a);
gives b: fooo\nbar
Is there any other function to escape string? I'm looking for
something that doesn't require to make
On Thu, 09 Apr 2015 11:45:30 +
tcak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:
I have written a function as follows:
public bool setCookie(
string name,
string value,
long maxAgeInSeconds = long.min,
string expiresOnGMTDate=null,
On Thursday, 9 April 2015 at 17:38:42 UTC, Dennis Ritchie wrote:
I think it has something to do with Vindovs :)
*Windows
On Thursday, 9 April 2015 at 17:08:44 UTC, Dennis Ritchie wrote:
Operates a code normally, but still gives the error:
http://ideone.com/kDHMk5
I think it has something to do with Vindovs :)
-
http://dpaste.dzfl.pl/4c5bb9dd0ffa
On Thu, 09 Apr 2015 11:04:47 -0400
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Note that the bad behavior (which was just fixed BTW) is
if(somearr), which used to mean if(somearr.ptr), and now it's a
compiler error.
-Steve
Yeah, because of this I
On Thu, 09 Apr 2015 11:04:47 -0400
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Note that the bad behavior (which was just fixed BTW) is
if(somearr), which used to mean if(somearr.ptr), and now it's a
compiler error.
-Steve
Yeah, because of this I
On Thursday, 9 April 2015 at 14:30:07 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote:
By the way, I am using DMD64 D Compiler v2.067.0 on Ubuntu
14.04.
I have Archlinux DMD64 D Compiler v2.067.0
On Thursday, 9 April 2015 at 13:32:38 UTC, Adam D. Ruppe wrote:
Don't use string == null, it is true for empty strings since
null and an empty string are almost interchangable.
You can try if(string is null) - is instead of ==. Though
usually in D, I just if(string.length == 0) and treat
wobbles:
Have just tested, it is!
But with the current D front-end it's not a good idea to generate
too many combinations at compile-time. Efficient code doesn't
save you from bad usages.
Bye,
bearophile
On Thursday, 9 April 2015 at 09:49:39 UTC, wobbles wrote:
So, I'm writing a poker AI bot. The idea was to generate a
lookup table of all the poker hands using CTFE so runtime can
be as quick as possible (as the bot has a very small amount of
time to act).
There are a LOT of calculations
On 4/9/15 9:32 AM, Adam D. Ruppe wrote:
Don't use string == null, it is true for empty strings since null and an
empty string are almost interchangable.
I think this is not good advice. Comparing string to null is perfectly
fine with ==. It's fine *because* null and empty strings are the same
On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote:
On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote:
By the way, I am using DMD64 D Compiler v2.067.0 on Ubuntu
14.04.
I have Archlinux DMD64 D Compiler v2.067.0 and it works OK for
me.
WOW
rdmd app.d(without params):
Name:
On Thursday, 9 April 2015 at 11:09:43 UTC, John Colvin wrote:
On Thursday, 9 April 2015 at 11:04:00 UTC, Dennis Ritchie wrote:
Hi,
Is it allowed in D similar designs?
void main() {
import std.stdio;
return writeln(Hello, world!);
}
Yes, because writeln returns nothing, but
I have written a function as follows:
public bool setCookie(
string name,
string value,
long maxAgeInSeconds = long.min,
string expiresOnGMTDate=null,
string path=null,
string domain=null,
bool secure=false
) shared{
// if headers
On Thursday, 9 April 2015 at 11:04:00 UTC, Dennis Ritchie wrote:
Hi,
Is it allowed in D similar designs?
void main() {
import std.stdio;
return writeln(Hello, world!);
}
It seems that you can not do so because writeln() something back,
which leads to RUNTIME_ERROR in DMD
I quite often have to write similar designs:
-
import std.stdio;
void main() {
auto a = [ 1, 2, 3, 4, 5 ];
foreach (e; a) {
if (e == 4) {
writeln(Yes);
return;
}
}
On Thursday, 9 April 2015 at 16:02:01 UTC, Dennis Ritchie wrote:
On Thursday, 9 April 2015 at 11:04:00 UTC, Dennis Ritchie wrote:
Hi,
Is it allowed in D similar designs?
void main() {
import std.stdio;
return writeln(Hello, world!);
}
It seems that you can not do so because
On Thursday, 9 April 2015 at 15:04:47 UTC, Steven Schveighoffer
wrote:
You can try if(string is null) - is instead of ==. Though
usually in D,
I just if(string.length == 0) and treat empty and null the
same way.
This is likely not what you want, it's generally not important
where a string is
On 04/08/15 18:10, Jens Bauer via Digitalmars-d-learn wrote:
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote:
On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote:
enum weak = gcc.attribute.attribute(weak);
enum isrDefault = gcc.attribute.attribute(alias, defaultHandler);
Am Wed, 08 Apr 2015 17:01:43 +
schrieb ZILtoid1991 ziltoidtheomnic...@gmail.com:
While I technically finished the 0.2 version of my graphics
engine which has a reasonable speed at low internal resolutions
and with only a couple of sprites, but it still gets bottlenecked
a lot. First
On Thursday, 9 April 2015 at 11:04:00 UTC, Dennis Ritchie wrote:
Hi,
Is it allowed in D similar designs?
void main() {
import std.stdio;
return writeln(Hello, world!);
}
Yes, because writeln returns nothing, but why would you do that?
Just put the return on the next line,
On Thursday, 9 April 2015 at 11:05:22 UTC, John Colvin wrote:
On Thursday, 9 April 2015 at 10:23:06 UTC, wobbles wrote:
On Thursday, 9 April 2015 at 10:04:09 UTC, John Colvin wrote:
On Thursday, 9 April 2015 at 09:49:39 UTC, wobbles wrote:
Another possibilty I was looking at was to write a
On Thursday, 9 April 2015 at 10:23:06 UTC, wobbles wrote:
On Thursday, 9 April 2015 at 10:04:09 UTC, John Colvin wrote:
On Thursday, 9 April 2015 at 09:49:39 UTC, wobbles wrote:
Another possibilty I was looking at was to write a tool that
will spit out all combinations at runtime, and then
On 9/04/2015 11:03 p.m., Dennis Ritchie wrote:
Hi,
Is it allowed in D similar designs?
void main() {
import std.stdio;
return writeln(Hello, world!);
}
Sure when:
import std.traits : ReturnType;
import std.stdio : writeln;
static assert(is(ReturnType!writeln == int));
By the way, I am using DMD64 D Compiler v2.067.0 on Ubuntu
14.04.
Hi ! I wonder how to escape a string in phobos ?
For example
auto a = [ fooo\nbar ];
auto b = format(%(%s%), a);
gives b: fooo\nbar
Is there any other function to escape string? I'm looking for
something that doesn't require to make an array at first.
For example is there string
Jack Applegame:
writeln(a.find(4).empty ? No : Yes);
canFind?
Bye,
bearophile
On Thursday, 9 April 2015 at 12:57:26 UTC, Jack Applegame wrote:
I quite often have to write similar designs:
-
import std.stdio;
void main() {
auto a = [ 1, 2, 3, 4, 5 ];
foreach (e; a) {
if (e == 4) {
writeln(Yes);
On Thursday, 9 April 2015 at 16:55:00 UTC, John Colvin wrote:
Try running your code somewhere where you can actually see the
output properly. RUNTIME_ERROR isn't something I recognise from
D.
Operates a code normally, but still gives the error:
http://ideone.com/kDHMk5
On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote:
By the way, I am using DMD64 D Compiler v2.067.0 on Ubuntu
14.04.
I have Archlinux DMD64 D Compiler v2.067.0 and it works OK for me.
http://stackoverflow.com/questions/29541229/d-how-to-use-binding-to-c-lib-with-d
On Thursday, 9 April 2015 at 12:06:49 UTC, Daniel Kozák wrote:
On Thu, 09 Apr 2015 11:45:30 +
tcak via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Can you post full example somewhere, this code works ok for me:
import std.stdio;
import std.datetime;
class Response
{
On Tuesday, 7 April 2015 at 22:15:13 UTC, Sönke Ludwig wrote:
Am 26.03.2015 um 02:38 schrieb Laeeth Isharc:
On Thursday, 26 March 2015 at 01:04:06 UTC, Jakob Ovrum wrote:
On Thursday, 26 March 2015 at 00:41:50 UTC, Laeeth Isharc
wrote:
Yeah, it is not very intuitive. But it works.
Thanks.
On Thursday, 9 April 2015 at 11:38:26 UTC, Rikki Cattermole wrote:
On 9/04/2015 11:22 p.m., John Colvin wrote:
On Thursday, 9 April 2015 at 11:07:05 UTC, Rikki Cattermole
wrote:
On 9/04/2015 11:03 p.m., Dennis Ritchie wrote:
Hi,
Is it allowed in D similar designs?
void main() {
import
47 matches
Mail list logo