I was messing about with std.concurrency and ran in to this:
http://dpaste.dzfl.pl/5655cbbe
copied out for those who don't want to go to dpaste:
import std.concurrency;
import std.stdio;
void main() {
double[] a,b;
a = [1.1];
b = [2.2];
int i= 3;
auto tid = spawn(&foo);
On Tuesday, 19 February 2013 at 16:23:45 UTC, Chris wrote:
I have written a DLL that I load into a Python program.
Everything works fine (DLL is loaded via ctypes, functions can
be called and are executed). Only the string handling is giving
me a bit of a headache. The string in D is always com
On Tuesday, 19 February 2013 at 19:06:47 UTC, jerro wrote:
D doesn't use null termination for it's strings, strings are
immutable(char)[]. You can form a D slice from a pointer by
going
slice = ptr[0..length]
where length is the length of the array the pointer represents.
You can't just take a
On Wednesday, 20 February 2013 at 14:28:06 UTC, Chris wrote:
On Wednesday, 20 February 2013 at 14:05:40 UTC, Mike Parker
wrote:
Your function is being called from Python, correct? Then in
addition to the extern(C), the argument needs to be a char*,
not a D array or a reference to one.
Correct
On Thursday, 21 February 2013 at 12:40:37 UTC, Lubos Pintes wrote:
Hi,
Can someone tell me an algorithm which determines if a file
specified by its name was modified today?
I suspect that I will need a std.datetime module to work with
dates, and something from somewhere that would tell me the
On Sunday, 3 March 2013 at 14:05:02 UTC, Sparsh Mittal wrote:
I am running
enum long DIM = 1024L * 1024L * 1024L* 8L ;
void main() {
auto signal = new double[DIM];
}
and getting core.exception.OutOfMemoryError error. One option
is to use short/int, but I need to use double. Also, on using
On Sunday, 3 March 2013 at 15:52:49 UTC, John Colvin wrote:
On Sunday, 3 March 2013 at 14:05:02 UTC, Sparsh Mittal wrote:
I am running
enum long DIM = 1024L * 1024L * 1024L* 8L ;
void main() {
auto signal = new double[DIM];
}
and getting core.exception.OutOfMemoryError error. One option
On Sunday, 3 March 2013 at 16:02:31 UTC, Sparsh Mittal wrote:
Assuming double.sizeof==8 on your machine, You're requesting
1024*1024*1024*8*8 bytes = 68GB, do you have that much RAM
available?
You are completely correct, however in C, one could do:
const long DIM = 1024L * 1024L * 1024L* 8L
On Tuesday, 12 March 2013 at 12:11:58 UTC, weltensturm wrote:
Why isn't it allowed to implicitly cast shared data to normal
data, or will that be part of the final implementation? It's a
bit annoying to cast everything back when using external
libraries.
Because there are no guarantees about
On Thursday, 14 March 2013 at 13:58:45 UTC, n00b wrote:
I tried to use a boolean operator for an array operation :
a[] = b[] < c[];
It compiles but seems to only fill a[] with the result of b[0]
< c[0].
Is there any "rational" reason to that?
And is there any way to use boolean operator for a
On Thursday, 14 March 2013 at 00:52:41 UTC, Timon Gehr wrote:
On 03/14/2013 01:48 AM, Jeremy DeHaan wrote:
Hey guys!
I am working on a binding for D, and am almost finished! I
started to
think of some things I might like to work on to improve the
binding
after I get everything working, and on
On Thursday, 14 March 2013 at 10:39:11 UTC, Jack Applegame wrote:
What does mean attribute shared exactly for non global
variables? Is it safe to cast to/from shared?
For example, let us assume all data are synchronized properly.
Is following code safe?
import core.atomic;
class A {
int v
On Saturday, 16 March 2013 at 15:29:03 UTC, Peter Sommerfeld
wrote:
Cannot find a reference: What is the best way
to catenate a string multiple times ?
Unfortunately this this does not work ;-)
string tab = "..";
tab = tab * 4; // -> ""
Peter
There are very many different ways of doin
On Saturday, 16 March 2013 at 15:58:32 UTC, John Colvin wrote:
On Saturday, 16 March 2013 at 15:29:03 UTC, Peter Sommerfeld
wrote:
Cannot find a reference: What is the best way
to catenate a string multiple times ?
Unfortunately this this does not work ;-)
string tab = "..";
tab
On Sunday, 17 March 2013 at 12:54:24 UTC, simendsjo wrote:
I get a lot of these errors, and they can be quite tricky to
get around and hurts my API.. Is this a temporary restriction
in DMD, or is it another reason why this doesn't work?
Error: template instance template!local cannot use local
On Tuesday, 19 March 2013 at 11:46:14 UTC, monarch_dodra wrote:
On Tuesday, 19 March 2013 at 10:08:43 UTC, Jonathan M Davis
wrote:
On Tuesday, March 19, 2013 09:25:43 timotheecour wrote:
we need a std.algorithm.equalRecurse(T1,T2)(T1 a, T2 b) that
compares recursively a and b;
its behavior sho
On Tuesday, 19 March 2013 at 12:16:54 UTC, John Colvin wrote:
On Tuesday, 19 March 2013 at 11:46:14 UTC, monarch_dodra wrote:
On Tuesday, 19 March 2013 at 10:08:43 UTC, Jonathan M Davis
wrote:
On Tuesday, March 19, 2013 09:25:43 timotheecour wrote:
we need a std.algorithm.equalRecurse(T1,T2
On Tuesday, 19 March 2013 at 12:16:54 UTC, John Colvin wrote:
(except if you feed it two integer literals, in which case the
compiler throws an out of memory error!).
Which is a legitimate error, seeing as -1 as a size_t is
size_t.max which meant replicate was requesting size_t.max
On Tuesday, 19 March 2013 at 12:34:04 UTC, monarch_dodra wrote:
On Tuesday, 19 March 2013 at 12:11:50 UTC, bearophile wrote:
Jonathan M Davis:
Going beyond a range of ranges is likely to be quite rare,
I agree.
and when it does happen, you can simply nest equal as many
times as you need.
On Tuesday, 19 March 2013 at 12:36:34 UTC, John Colvin wrote:
On Tuesday, 19 March 2013 at 12:34:04 UTC, monarch_dodra wrote:
On Tuesday, 19 March 2013 at 12:11:50 UTC, bearophile wrote:
Jonathan M Davis:
Going beyond a range of ranges is likely to be quite rare,
I agree.
and when it
On Tuesday, 19 March 2013 at 08:25:45 UTC, timotheecour wrote:
we need a std.algorithm.equalRecurse(T1,T2)(T1 a, T2 b) that
compares recursively a and b;
its behavior should be:
if opEqual is defined, call it
The problem is, Object defines opEqual as "bool opEquals(Object
o){return this is
On Saturday, 23 March 2013 at 17:08:27 UTC, dsmith wrote:
How to make workable something like this:
struct S (T...) {
T args;
string arg_str;
foreach(i; args) {
arg_str ~ to!string(i);
}
}
void some_function(S s) { // here ... Error: struct S(T...)
is used as a type
s.args =
I've been learning assembler a bit and I decided to have a look
at what dmd spits out. I tried a simple function with arrays to
see what vectorization gets done
void addto(int[] a, int[] b) {
a[] += b[];
}
dmd -O -release -inline -noboundscheck -gc -c test.d
disassembled with gdb:
_D3sse5
On Monday, 1 April 2013 at 02:03:12 UTC, bearophile wrote:
In what you are seeing I think something is not recognizing
the SSE+ instructions.
Sorry, I was wrong. The SSE ops are done elsewhere. You see
that "call 0x7b <_D3sse5addtoFAiAiZv+59>".
Bye,
bearophile
Woops, sorry the actual fil
On Monday, 1 April 2013 at 11:10:56 UTC, Artur Skawina wrote:
On 04/01/13 12:24, js.mdnq wrote:
On Monday, 1 April 2013 at 01:54:10 UTC, John Colvin wrote:
What's after the code?
The 0x76 call is an inline call function, the ret returns it.
The stuff before it is setting up the register
On Tuesday, 2 April 2013 at 16:24:46 UTC, WhatMeWorry wrote:
I don't suppose there is a digital.D.beginner forum?
I've been staring at this definition for about an hour and I
still can't decode it.
int[string][double[int[]]] a; //
...
auto b = to!(short[wstring][string[double[]]])(a); // t
On Tuesday, 2 April 2013 at 16:51:45 UTC, Tobias Pankrath wrote:
On Tuesday, 2 April 2013 at 16:24:46 UTC, WhatMeWorry wrote:
I don't suppose there is a digital.D.beginner forum?
There is D.learn. Scroll down in the webinterface :-)
This is in D.learn already.
int[string} a // would be a
On Wednesday, 3 April 2013 at 11:05:06 UTC, Tobias Pankrath wrote:
basic idea.
---
T x;
T* px = new T(x);
---
int x
int* px = new int(x); // fails
---
I need to do this for structs and basic types. What's the
standard way to do this?
Do you need to use new? i.e. do you need the variable to be
On Wednesday, 3 April 2013 at 15:25:22 UTC, Tobias Pankrath wrote:
On Wednesday, 3 April 2013 at 14:47:22 UTC, John Colvin wrote:
On Wednesday, 3 April 2013 at 11:05:06 UTC, Tobias Pankrath
wrote:
basic idea.
---
T x;
T* px = new T(x);
---
int x
int* px = new int(x); // fails
---
I need to do
On Wednesday, 3 April 2013 at 16:13:02 UTC, Andrej Mitrovic wrote:
On 4/3/13, John Colvin wrote:
note: this is not C malloc, the memory is requested from and
managed by the GC.
Shouldn't that call be GC.malloc? I don't see a module-scoped
malloc
function anywhere except th
On Wednesday, 3 April 2013 at 16:39:18 UTC, Ali Çehreli wrote:
That assignment will fail in general when the left-hand side
has those undetermined bits.
Could you expand on this? I don't fully understand.
On Thursday, 4 April 2013 at 01:06:45 UTC, Steve Kucera wrote:
Hi,
I am using DMD 2.062 on Windows 7 64-bit.
I am writing performance critical functions that need switch
statements to use an indirect jump table... current I'm
analysing the assembly dump, and the code is compiled to nested
if
On Thursday, 4 April 2013 at 09:51:15 UTC, John Colvin wrote:
On Thursday, 4 April 2013 at 01:06:45 UTC, Steve Kucera wrote:
Hi,
I am using DMD 2.062 on Windows 7 64-bit.
I am writing performance critical functions that need switch
statements to use an indirect jump table... current I
On Tuesday, 16 April 2013 at 05:37:48 UTC, Tofu Ninja wrote:
I could not think of what to call this because I don't know if
it has a name to call it by.
Basicly what I was wondering is if their was a way in D to make
a class function pass the object being called on by reference.
might be eas
On Tuesday, 16 April 2013 at 14:33:21 UTC, John Colvin wrote:
A member function cannot modify it's own 'this' pointer.
However, a free function can do it happily, which when combined
with UFCS gives you the same syntax and behaviour:
class A {
//..
}
void
On Tuesday, 16 April 2013 at 14:57:11 UTC, Tofu Ninja wrote:
On Tuesday, 16 April 2013 at 14:33:21 UTC, John Colvin wrote:
A member function cannot modify it's own 'this' pointer.
However, a free function can do it happily, which when
combined with UFCS gives you the same synta
On Wednesday, 17 April 2013 at 01:41:58 UTC,
[email protected] wrote:
File efile;
writefln("command line %s", args[]);
if(args.length == 3) {
type = to!int( args[1] );
// writefln("args[2] is: %s",args[2]);
}
if (args.length == 2) {
efile = File(args[2]);
On Thursday, 18 April 2013 at 18:04:03 UTC, Andrej Mitrovic wrote:
On 4/18/13, gedaiu wrote:
i've done that but i get this error:
Error: function base.Value.Value.toString cannot override a
non-virtual function
Error: function base.Value.Value.toString override only applies
to class member fun
On Thursday, 18 April 2013 at 18:46:09 UTC, gedaiu wrote:
i have a struct not an object.
There's a slight nomenclature clash here:
Object is the base class in D. Therefore one could say that an
object is an instatiation of Object and therefore a class.
However, by a wider definition of the
On Saturday, 20 April 2013 at 13:37:55 UTC, John Colvin wrote:
On Saturday, 20 April 2013 at 12:23:20 UTC, deed wrote:
import std.stdio : writeln;
template Template (uint n, T)
{
T[n] statArr()
{
T[n] arr;
return arr;
}
T[] dynArr()
{
T[] dynArr = new T[n
On Saturday, 20 April 2013 at 12:23:20 UTC, deed wrote:
import std.stdio : writeln;
template Template (uint n, T)
{
T[n] statArr()
{
T[n] arr;
return arr;
}
T[] dynArr()
{
T[] dynArr = new T[n];
return dynArr;
}
}
void main()
{
alias
On Saturday, 20 April 2013 at 12:23:20 UTC, deed wrote:
import std.stdio : writeln;
template Template (uint n, T)
{
T[n] statArr()
{
T[n] arr;
return arr;
}
T[] dynArr()
{
T[] dynArr = new T[n];
return dynArr;
}
}
void main()
{
alias
On Saturday, 20 April 2013 at 13:37:55 UTC, John Colvin wrote:
On Saturday, 20 April 2013 at 12:23:20 UTC, deed wrote:
import std.stdio : writeln;
template Template (uint n, T)
{
T[n] statArr()
{
T[n] arr;
return arr;
}
T[] dynArr()
{
T[] dynArr = new T[n
On Saturday, 20 April 2013 at 15:32:20 UTC, Andrej Mitrovic wrote:
On 4/20/13, Namespace wrote:
Why can D implicitly cast from the subclass to the base class,
but not implicitly from the subclasse pointer to the base class
pointer?
This works: http://dpaste.1azy.net/30dd34a0
This not: http://d
On Saturday, 20 April 2013 at 14:56:25 UTC, Namespace wrote:
Why can D implicitly cast from the subclass to the base class,
but not implicitly from the subclasse pointer to the base class
pointer?
This works: http://dpaste.1azy.net/30dd34a0
This not: http://dpaste.1azy.net/ffacfd83
Makes not
On Saturday, 20 April 2013 at 16:36:09 UTC, Namespace wrote:
It works fine in C++ (of course with -std=c++0x)
http://codepad.org/qLIjGGd4
It's been a while since I did any c++ but:
1) I don't see any pointer to pointer polymorphism in there.
2) That c++ code is equivalent to the version of yo
On Saturday, 20 April 2013 at 17:42:02 UTC, Namespace wrote:
And no, the equivalent version would use 'A' as return type of
'get', not 'A*'.
Sorry, no.
//C++
A* get(unsigned int id);
//D
A get(unsigned int id);
Those are the equivalent declarations. A reference is, for these
intents and pur
On Saturday, 20 April 2013 at 21:36:37 UTC, John Colvin wrote:
On Saturday, 20 April 2013 at 17:42:02 UTC, Namespace wrote:
And no, the equivalent version would use 'A' as return type of
'get', not 'A*'.
Sorry, no.
//C++
A* get(unsigned int id);
//D
A get(un
On Friday, 26 April 2013 at 17:55:59 UTC, mab wrote:
Thank you for answering. But it didnt work.
I get:
#dmd hello.d -L-lcurl
/usr/bin/ld: cannot find -lcurl
collect2: ld returned 1 exit status
--- errorlevel 1
Curl is installed, as also libcurl3.
I forget to mention that i am using "DMD64 D C
On Sunday, 28 April 2013 at 19:45:41 UTC, Namespace wrote:
That surprised me a bit. Is that expected?
import std.stdio;
struct A { }
interface IFoo {
void bar(ref const A);
}
class Foo : IFoo {
void bar(ref const A a) {
}
void bar
On Monday, 29 April 2013 at 09:23:01 UTC, Namespace wrote:
Not surprising to me at all. Why would ref be covariant with
non-ref?
I do not understand the error fully. Why I cannot overload the
method in the class with non-ref?
Sorry, my mistake, it looks like a bug. Dmd thinks that you're
tr
On Wednesday, 1 May 2013 at 08:42:40 UTC, Temtaime wrote:
I'm new in D, so i'm tried to write some in that langugage.
That's story about how i tried to port OGL sample, that renders
one triangle.
I was very surprised when i found, that D doesn't have
equivalent of gl/gl.h. Any C++ compiler ha
On Wednesday, 1 May 2013 at 08:42:40 UTC, Temtaime wrote:
I'm new in D, so i'm tried to write some in that langugage.
That's story about how i tried to port OGL sample, that renders
one triangle.
I was very surprised when i found, that D doesn't have
equivalent of gl/gl.h. Any C++ compiler ha
On Wednesday, 1 May 2013 at 21:26:32 UTC, Temtaime wrote:
Because it's full of a drawing and many other functions. OpenGL
is part of WinAPI.
Is that strictly speaking true? I didn't think opengl was part of
the windows api (WinAPI) itself.
Anyway, afaik opengl is not provided by c/c++ compil
On Tuesday, 7 May 2013 at 10:29:44 UTC, Namal wrote:
Hello,
I am new to D. According to that power of 2 rule I want to
reserve 2 sized chunks to my array, But how do I do that in a
struct? Say:
struct Stack(int){
int a[];
}
"2 sized chunks"?
Perhaps you want something like this:
struct
On Tuesday, 7 May 2013 at 11:49:07 UTC, evilrat wrote:
On Tuesday, 7 May 2013 at 10:58:42 UTC, John Colvin wrote:
...
int a[];
please don't use C style declarations, D style is "type
followed by id":
int[] a;
woops, just copied it from the original post.
On Thursday, 9 May 2013 at 19:32:44 UTC, Zz wrote:
Hi,
I decided to try out kxml and I have the following error.
test.d(10): Error: found '.' when expecting ','
test.d(11): Error: found '.' when expecting ','
when the following is compiled.
module test;
import kxml.xml;
private import std.st
On Monday, 13 May 2013 at 00:18:34 UTC, D-Ratiseur wrote:
I went back from a trip...basically I spent 6 monthes in
Yukon...
Then, came back to my activities, I was a lot in the library of
the university linked to my geo. location...I've noticed a
strange guy...He was always reading some books a
On Wednesday, 22 May 2013 at 08:38:14 UTC, Stephan Schiffels
wrote:
Hi,
this code crashes with a segfault. I need help to understand
what might be wrong with it.
import std.array;
import std.algorithm;
void main() {
auto names = ["file1.txt", "file2.txt", "file3.txt"]; // let
these files
On Wednesday, 22 May 2013 at 11:07:39 UTC, bearophile wrote:
Stephan Schiffels:
this code crashes with a segfault. I need help to understand
what might be wrong with it.
import std.array;
import std.algorithm;
void main() {
auto names = ["file1.txt", "file2.txt", "file3.txt"]; // let
thes
On Thursday, 23 May 2013 at 16:27:19 UTC, Gary Willoughby wrote:
Why won't the following code compile? Here's the error:
filewatcher.d(21): Error: cannot implicitly convert expression
(new File(file, "r")) of type File* to shared(_iobuf)*
/**
* Imports.
*/
import std.stdio;
/**
* A class
On Saturday, 25 May 2013 at 18:28:09 UTC, Diggory wrote:
D has to know the context for a template mixing at the point
where it is declared rather than where it is used.
Quite the opposite in fact. Templates exist in the context that
they are defined in, mixin templates in the context where the
On Sunday, 26 May 2013 at 12:08:41 UTC, Joseph Rushton Wakeling
wrote:
On 05/24/2013 05:59 PM, Ali Çehreli wrote:
The following simple example uses mutable data but it should
work with 'const' too.
Limiting ourselves to read-only, won't there still be a
slowdown caused by
multiple threads try
On Tuesday, 28 May 2013 at 11:49:25 UTC, Gary Willoughby wrote:
Why does the following snippet print:
"Started name revision" instead of "Started my-app 1.0a"?
import std.stdio;
enum application : string
{
name = "my-app",
revision = "1.0a",
}
void main(string[] arguments)
On Tuesday, 28 May 2013 at 12:16:51 UTC, John Colvin wrote:
There really ought to be a property .value of enums.
or alternatively .name of course. Either way there should be a
way to choose whether you want the name or the value.
On Thursday, 30 May 2013 at 16:18:44 UTC, Shriramana Sharma wrote:
Hello. I have always loved the readability of C++'s
and/or/not/xor
word-like logical operators but It doesn't seem to be available
in D.
Isn't this possible in D? I tried doing:
alias && and ;
import std.stdio ;
void main () {
On Friday, 31 May 2013 at 10:21:19 UTC, Regan Heath wrote:
Until this thread I didn't even know they existed..
Same.
I use them every day in python, but I had no idea they were in C++
Tbh they annoy me in python, although that's just my C background
showing.
On Friday, 31 May 2013 at 17:14:46 UTC, Shriramana Sharma wrote:
import std.stdio ;
void foo ( int[] array ) {
foreach ( i ; array ) { writeln ( i ) ; }
}
void main () {
foo ( [ 1, 2, 3 ] ) ;
}
On both DMD 2.062 and 2.063 this compiles OK but causes a
segfault.
I'm running Ku
On Friday, 31 May 2013 at 18:22:44 UTC, Shriramana Sharma wrote:
On Fri, May 31, 2013 at 11:46 PM, John Colvin
wrote:
Can't reproduce this. Any chance of a stacktrace and/or
disassembly?
Please give instructions as to how I can get either of those
two for
you. Would you like the b
On Friday, 31 May 2013 at 16:17:28 UTC, Ali Çehreli wrote:
On 05/31/2013 04:28 AM, Shriramana Sharma wrote:
> On Fri, May 31, 2013 at 4:31 PM, Timon Gehr
wrote:
>>
>> If double uses xmm registers and real uses the fpu registers
(as is standard
>> on x64), then double multiplication has twice th
On Wednesday, 5 June 2013 at 09:02:44 UTC, Regan Heath wrote:
On Tue, 04 Jun 2013 23:47:07 +0100, ixid
wrote:
On Monday, 3 June 2013 at 09:29:20 UTC, Regan Heath wrote:
On Fri, 31 May 2013 21:26:56 +0100, ixid
wrote:
We really don't want D to become a TMTOWTDI language.
Ideally there sh
On Wednesday, 5 June 2013 at 22:25:21 UTC, Adam D. Ruppe wrote:
3) prop += 5 and friends
This is the biggest deal for me. Being able to write all these
read-modify-write operators on properties would simplify writing
transparent wrapper types so much.
On Monday, 10 June 2013 at 02:02:09 UTC, Timothee Cour wrote:
UFCS chains are problematic when a symbol is ambiguous (eg
after import
std.stdio:write;import std.file:write);
I previously suggested to add the syntax
'arg1.(std.file.write)(arg2)'
(see 'support UFCS with fully qualified function n
On Monday, 10 June 2013 at 09:46:42 UTC, snow wrote:
Hello,
I searched a lot in the docs and search, but couldn't find
anything so far. Is there a funtion, which converts my decimal
number into a binary?
I presume your decimal is in a string?
use
std.conv.parse
or
std.conv.to
On Tuesday, 11 June 2013 at 18:47:08 UTC, timotheecour wrote:
On Monday, 10 June 2013 at 08:13:42 UTC, John Colvin wrote:
On Monday, 10 June 2013 at 02:02:09 UTC, Timothee Cour wrote:
UFCS chains are problematic when a symbol is ambiguous (eg
after import
std.stdio:write;import std.file:write
On Tuesday, 11 June 2013 at 20:46:32 UTC, Craig Dillabaugh wrote:
I was looking at D code for constructing kd-trees, the full code
listing for which can be found here:
http://rosettacode.org/wiki/K-d_tree#Faster_Alternative_Version
Of particular interest were the following functions:
KdNode* m
On Tuesday, 11 June 2013 at 22:13:18 UTC, bearophile wrote:
If you want to do benchmarks don't forget to do them with a
better compiler, like LDC2, that is able to use that
compile-time information to optimize better.
When I have written that code I was using only DMD. I have just
started t
On Wednesday, 19 June 2013 at 11:33:43 UTC, deed wrote:
Should this be a compile time error?
Yes it should, in an ideal world. Expanding out the assign
property, what we've got is:
void var(int i)
{
var(i); // endless recursion.
}
Linux segfaults on stack overflow, so that's your cra
On Friday, 21 June 2013 at 11:33:29 UTC, monarch_dodra wrote:
On Friday, 21 June 2013 at 10:09:10 UTC, Gary Willoughby wrote:
Have you any tips for using D when you need fast string
concatenation? I regularly use code like this:
foreach (i, range)
{
foo ~= bar;
}
or:
foo =
On Wednesday, 26 June 2013 at 20:51:35 UTC, Gary Willoughby wrote:
Just for a bit of fun, I saw this question posted on reddit the
other day and wondered how *you* would solve this in D?
http://stackoverflow.com/questions/731832/interview-question-ffn-n
The question is ambiguous as to what th
On Thursday, 27 June 2013 at 12:38:25 UTC, John Colvin wrote:
Woops, sorry missed an assert
unittest
{
assert(f(f(int.min)) == -(cast(long)int.min));
foreach(int n; int.min + 1 .. int.max)
{
assert(f(f(n)) == -n);
}
assert(f(f(int.max
On Wednesday, 26 June 2013 at 23:14:09 UTC, H. S. Teoh wrote:
I think the 4-cycle algorithm is
probably still the best one I've seen.
All (correct) mathematically based answers are 4-cycle.
begin very sloppy proof with mixed up notation:
Let f^2(x) = -x
f^4(x) = f^2(f^2(x))
= f^2(-x)
On Thursday, 27 June 2013 at 15:32:05 UTC, MattCodr wrote:
On Thursday, 27 June 2013 at 12:38:25 UTC, John Colvin wrote:
The question is ambiguous as to what they mean by -n. Do they
mean the result of negation on the 32bit signed int, or do
they mean the negative of the number represented by
On Thursday, 27 June 2013 at 18:00:21 UTC, Steven Schveighoffer
wrote:
On Thu, 27 Jun 2013 13:43:24 -0400, Steven Schveighoffer
wrote:
On Wed, 26 Jun 2013 16:51:33 -0400, Gary Willoughby
wrote:
Just for a bit of fun, I saw this question posted on reddit
the other day and wondered how *you
On Thursday, 27 June 2013 at 18:37:26 UTC, Timon Gehr wrote:
On 06/26/2013 10:51 PM, Gary Willoughby wrote:
Just for a bit of fun, I saw this question posted on reddit
the other
day and wondered how *you* would solve this in D?
http://stackoverflow.com/questions/731832/interview-question-ffn-n
On Thursday, 27 June 2013 at 22:31:21 UTC, Timon Gehr wrote:
On 06/27/2013 09:48 PM, John Colvin wrote:
On Thursday, 27 June 2013 at 18:37:26 UTC, Timon Gehr wrote:
On 06/26/2013 10:51 PM, Gary Willoughby wrote:
Just for a bit of fun, I saw this question posted on reddit
the other
day and
Is there any way of getting the body of a function as a string?
(Obviously only when the source code is available to the compiler)
On Friday, 28 June 2013 at 13:18:39 UTC, bearophile wrote:
John Colvin:
Is there any way of getting the body of a function as a
string? (Obviously only when the source code is available to
the compiler)
I think that currently there isn't a simple way to do it. What
is your use case?
void main()
{
template A(alias a)
{
enum A = a.stringof;
}
int b;
string s = A!b; // Error: template instance A!(b) cannot use
local 'b' as parameter to non-global template A(alias a)
}
Bug or feature?
On Friday, 28 June 2013 at 13:55:54 UTC, Namespace wrote:
And why don't you call the function from your clone function?
Because the body of the new function needs to see the parameters
as known at compile-time.
Maybe this could help you: http://dpaste.1azy.net/fork/597affd2
I used it to gen
On Friday, 28 June 2013 at 23:57:30 UTC, Ali Çehreli wrote:
On 06/28/2013 01:04 PM, John Colvin wrote:
void main()
{
template A(alias a)
{
enum A = a.stringof;
}
int b;
string s = A!b; // Error: template instance A!(b) cannot
use
local 'b' as parame
On Monday, 1 July 2013 at 19:15:45 UTC, Gary Willoughby wrote:
If you remove the the try..catch you will notice that
OwnerTerminated is
thrown, if this is the intended behaviour, I don't know.
Probably is,
because this would be a pretty obvious bug.
Ah right, so i guess the main thread is fin
On Monday, 1 July 2013 at 18:09:32 UTC, Jonathan M Davis wrote:
On Monday, July 01, 2013 18:32:30 CJS wrote:
Is there some header/module that includes declaration for all C
standard libraries?
I'm wondering both in general for future reference, and for the
specific case of wanting to time a fun
Is there any way to take the address of any of an overloaded set
of functions?
import std.stdio;
void foo(int a){ writeln("overload int"); }
void foo(long b){ writeln("overload long"); }
void main()
{
auto b = &foo; //ambiguous => error
b(2); //valid for either overload
}
On Wednesday, 3 July 2013 at 15:05:00 UTC, Dicebot wrote:
On Wednesday, 3 July 2013 at 14:52:32 UTC, John Colvin wrote:
Is there any way to take the address of any of an overloaded
set of functions?
import std.stdio;
void foo(int a){ writeln("overload int"); }
void foo(long b
On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote:
On 07/03/13 16:52, John Colvin wrote:
Is there any way to take the address of any of an overloaded
set of functions?
import std.stdio;
void foo(int a){ writeln("overload int"); }
void foo(long b){ writeln(&quo
On Thursday, 4 July 2013 at 09:15:30 UTC, Dicebot wrote:
On Wednesday, 3 July 2013 at 15:17:49 UTC, John Colvin wrote:
It's a pity that only work within an aggregate (the
documentation actually says only classes)
http://dpaste.dzfl.pl/6866e094
Surprise! :P
Hooray :) I've submit
On Friday, 5 July 2013 at 20:47:45 UTC, Charles Hixson wrote:
I don't mean to come off as a formatting fascist, but you'll get
more responses from busy people if you format in a more familiar
way, e.g.
class Outer
{
int inn;
struct InnerS
{
int able;
void setable(
On Friday, 5 July 2013 at 21:20:27 UTC, John Colvin wrote:
On Friday, 5 July 2013 at 20:47:45 UTC, Charles Hixson wrote:
I don't mean to come off as a formatting fascist, but you'll
get more responses from busy people if you format in a more
familiar way, e.g.
class Outer
{
On Sunday, 7 July 2013 at 17:04:24 UTC, Russel Winder wrote:
On Sun, 2013-07-07 at 07:50 -0700, H. S. Teoh wrote:
[…]
apt-cache search libcurl | grep dev
aptitude search libcurl.*dev
surely. :-)
to be honest, most of the time I would just write "apt-get
install licurl" and then look throug
1 - 100 of 853 matches
Mail list logo