On Mon, 18 Nov 2013 21:32:11 +0100, Philippe Sigaud wrote:
On Mon, Nov 18, 2013 at 9:20 PM, seany se...@uni-bonn.de wrote:
I read that book, but dont find this constructtion, that is why the
question.
IIRC I talk a bit about function templates in my tutorial. JR gave the
link (thanks!),
On Monday, 18 November 2013 at 20:32:25 UTC, Philippe Sigaud
wrote:
On Mon, Nov 18, 2013 at 9:20 PM, seany se...@uni-bonn.de
wrote:
I read that book, but dont find this constructtion, that is
why the
question.
IIRC I talk a bit about function templates in my tutorial. JR
gave the
link
this question came up in some C++ work I am doing, but since the
solutions are likely nicer in D, I wanted to ask how it could be
solved in D.
First for some motivation. I am doing image processing work
where the images are simply an array of data, where the data type
can be any numeric type.
Craig Dillabaugh:
// Assume images are of the same dimensions. Result is
// saved in Out.
void add(T,U,V)(Image!T A, Image!U B, Image!V Out) {
...
}
Take a look at the out annotation in D.
Anyway, thanks to whoever takes the time to read all that, let
alone come up with an answer.
Is there a built in function or operator in D that can compare
two arrays (prefereably any dimensional) for being elementwise
equal?
thnak you
On Tuesday, 19 November 2013 at 14:12:14 UTC, seany wrote:
Is there a built in function or operator in D that can compare
two arrays (prefereably any dimensional) for being elementwise
equal?
a == b works on single dimension. Not sure about beyond that
though.
Say I defined an array as int[] a = [1,2,3,4];
Now if I do a = function(a);
will that make a to equal [1,2,3,4,5]
the function is defined as:
int[] function(int[] b)
{ return b ~ 5;}
seany:
Say I defined an array as int[] a = [1,2,3,4];
Now if I do a = function(a);
will that make a to equal [1,2,3,4,5]
the function is defined as:
int[] function(int[] b)
{ return b ~ 5;}
D dynamic arrays are partially values, so use:
int[] function(ref int[] b)
Bye,
bearophile
Adam D. Ruppe:
a == b works on single dimension. Not sure about beyond that
though.
It works on nD arrays:
void main() {
immutable m1 = [[1, 2], [3, 4]];
immutable m2 = [[1, 2], [3, 4]];
immutable m3 = [[1, 2], [3, 5]];
assert(m1 == m2);
assert(m1 != m3);
assert(m1
You'd usually find stuff like this (i.e. generic algorithms that act on
collections) in std.algorithms
http://dlang.org/phobos/std_algorithm.html#equal
On Tue, Nov 19, 2013 at 3:12 PM, seany se...@uni-bonn.de wrote:
Is there a built in function or operator in D that can compare two arrays
If I have a function:
@safe pure void functionName() {
return;
}
Where do I put the noexcept?
On Tuesday, 19 November 2013 at 18:01:19 UTC, Jeroen Bollen wrote:
If I have a function:
@safe pure void functionName() {
return;
}
Where do I put the noexcept?
Did you mean nothrow?
You can put it unfortunately on both sides.
left:
@safe pure nothrow void
On Tuesday, 19 November 2013 at 18:09:29 UTC, Namespace wrote:
On Tuesday, 19 November 2013 at 18:01:19 UTC, Jeroen Bollen
wrote:
If I have a function:
@safe pure void functionName() {
return;
}
Where do I put the noexcept?
Did you mean nothrow?
You can put it
Is there a way I can call a receive method on a socket with
MSG_WAITALL as a flag? There doesn't seem to be an enum for that.
Consider this:
I have a function FUNC, it takes a string array, and does
something with it, and retruns the same. Implemented based on a
previous thread, here is what i have
string[] FUNC (ref string[] ZZ)
{
/*
do something
*/
}
and the calling is, ZZ = FUNC(ZZ)
Now, I want, should the
Uh I forgot to mention that it should do this without global
variables, and without try / catch
On Tuesday, 19 November 2013 at 19:15:10 UTC, seany wrote:
Consider this:
I have a function FUNC, it takes a string array, and does
something with it, and retruns the same. Implemented based on a
previous thread, here is what i have
string[] FUNC (ref string[] ZZ)
{
/*
do something
*/
}
seany:
I have a function FUNC, it takes a string array, and does
something with it, and retruns the same. Implemented based on a
previous thread, here is what i have
string[] FUNC (ref string[] ZZ)
I told you to use ref if you want to modify in-place the length
of the array, as in the
On 11/19/2013 11:15 AM, seany wrote:
Consider this:
I have a function FUNC, it takes a string array, and does something with
it, and retruns the same. Implemented based on a previous thread, here
is what i have
string[] FUNC (ref string[] ZZ)
{
/*
do something
*/
}
and the calling
On Tuesday, 19 November 2013 at 19:31:41 UTC, bearophile wrote:
A Nullable in usually efficient enough (there is even an
alternative Nullable that doesn't increase the data size), it
makes typing stronger, and it should become more common in
system languages (and indeed it's commonly used in
Anyone? I know it's a very basic question, but an honest and
friendly answer will suffice.
On Monday, 18 November 2013 at 23:49:56 UTC, Rick Catano wrote:
My first question of the D language is, is there a SOAP module
that I can consume web services with?
I don't know, but I don't think so. Maybe it wouldn't be too hard
to make out by combining http get (with curl or whatever) with
On Tuesday, 19 November 2013 at 20:38:00 UTC, Adam D. Ruppe wrote:
On Monday, 18 November 2013 at 23:49:56 UTC, Rick Catano wrote:
My first question of the D language is, is there a SOAP module
that I can consume web services with?
I don't know, but I don't think so. Maybe it wouldn't be too
I'm brand new to D and I'm taking on a project. In the midst,
I've overloaded a whole load of operators for my Vec3 class. Most
seem to be working (I haven't tested them all yet) but opEquals
is refusing to be called. I've followed the guidelines here:
On Tuesday, 19 November 2013 at 19:15:10 UTC, seany wrote:
(so i want liek a C style fopen -like function, that , although
called with the syntax: file *f = fopen(balh, bla); can set f
to be false)
I think you have a misunderstanding here. C does not allow you to
return false. Instead C
On Tuesday, 19 November 2013 at 20:59:31 UTC, Dale Matthews wrote:
I feel like I'm missing something simple.
opEquals doesn't work on classes with class references. It
doesn't call a method with obj = other_obj, it just rebinds the
reference. If you want full control over opEquals, it'll
On Tuesday, 19 November 2013 at 20:59:31 UTC, Dale Matthews wrote:
I'm brand new to D and I'm taking on a project. In the midst,
I've overloaded a whole load of operators for my Vec3 class.
Most seem to be working (I haven't tested them all yet) but
opEquals is refusing to be called. I've
If I have a hash-table `File[string] _subs` and want to access
its values in a sorted way is there a better than simply through
auto ssubs = new File[_subs.length]; // preallocate sorted
subs
size_t ix = 0;
foreach (sub; _subs) {
ssubs[ix++] = sub; // set new reference
On Tuesday, 19 November 2013 at 21:11:42 UTC, Nordlöw wrote:
If I have a hash-table `File[string] _subs` and want to access
its values in a sorted way is there a better than simply through
auto ssubs = new File[_subs.length]; // preallocate sorted
subs
size_t ix = 0;
foreach
On Tuesday, 19 November 2013 at 21:05:23 UTC, Adam D. Ruppe wrote:
opEquals doesn't work on classes with class references.
IGNORE ME, I am wrong here. I mixed up opEquals and opAssign in
my head.
Sorry!
This was a bug and has since been fixed, so the solution is
simply to update your compiler. If there is some reason you
can't (company required version, etc) then your cast() is sadly
probably the only way.
Dicebot:
I don't want to argue this in details right now but I think
that simply banning null references as valid arrays in program
as a whole via contracts is better approach than adding extra
level of indirection via Nullable ;)
Nullable is a struct, it doesn't introduce a new leavel of
On Tuesday, 19 November 2013 at 21:22:27 UTC, Adam D. Ruppe wrote:
IGNORE ME, I am wrong here. I mixed up opEquals and opAssign in
my head.
Sorry!
Will do :]
On Tuesday, 19 November 2013 at 21:10:57 UTC, Chris
Nicholson-Sauls wrote:
override bool opEquals (Object o) const {
if ( auto v = cast( typeof( this ) ) o )
return x == v.x y == v.y z == v.z;
return false;
}
You need:
1) 'override' in order to override
On Tuesday, 19 November 2013 at 21:25:47 UTC, Dale Matthews wrote:
Adam, do you recommend using a struct instead of a class?
Yes, I would use a struct instead of a class here. The key
question to ask in D is: do you need inheritance? If yes, use a
class, if no, struct is usually better,
is there any particular reason you are forced to use SOAP?
It is more or less an obsolete and generally frowned upon
approach.
if you were willing to adopt REST, vibe.d seems to have some nice
functionality for creating REST APIs.
Look at the 'Routing' section here:
On Tuesday, 19 November 2013 at 21:14:01 UTC, Brad Anderson wrote:
On Tuesday, 19 November 2013 at 21:11:42 UTC, Nordlöw wrote:
If I have a hash-table `File[string] _subs` and want to access
its values in a sorted way is there a better than simply
through
auto ssubs = new
On Tuesday, 19 November 2013 at 22:42:10 UTC, Nordlöw wrote:
On Tuesday, 19 November 2013 at 21:14:01 UTC, Brad Anderson
wrote:
On Tuesday, 19 November 2013 at 21:11:42 UTC, Nordlöw wrote:
If I have a hash-table `File[string] _subs` and want to
access its values in a sorted way is there a
On 11/19/2013 02:42 PM, Nordlöw wrote:
On Tuesday, 19 November 2013 at 21:14:01 UTC, Brad Anderson wrote:
On Tuesday, 19 November 2013 at 21:11:42 UTC, Nordlöw wrote:
If I have a hash-table `File[string] _subs` and want to access its
values in a sorted way is there a better than simply through
Well in C I just declared an array during execution with an array
with a multiplied variable for the size of the array.
Since I only need two spaces in the array for each line of
process it was multiplied by two.
so it was like this :
scanf(%d, Num);
int array[Num*2];
When I tried to do
On 11/19/2013 03:16 PM, Carlos wrote: Well in C I just declared an
array during execution with an array with a
multiplied variable for the size of the array.
Since I only need two spaces in the array for each line of process it
was multiplied by two.
so it was like this :
scanf(%d, Num);
On Tuesday, 19 November 2013 at 18:35:08 UTC, Jeroen Bollen wrote:
Is there a way I can call a receive method on a socket with
MSG_WAITALL as a flag? There doesn't seem to be an enum for
that.
module core.sys.posix.sys.socket;
enum : uint
{
MSG_CTRUNC = 0x08,
On Tuesday, 19 November 2013 at 06:11:26 UTC, Ali Çehreli wrote:
On 11/18/2013 07:48 PM, bioinfornatics wrote:
On Thursday, 14 November 2013 at 12:01:04 UTC, Ali Çehreli
wrote:
On 11/13/2013 04:32 PM, bioinfornatics wrote:
Hi,
I try to understand which type char, dchar, wchar will give
On Tuesday, 19 November 2013 at 23:53:33 UTC, bioinfornatics
wrote:
On Tuesday, 19 November 2013 at 06:11:26 UTC, Ali Çehreli wrote:
On 11/18/2013 07:48 PM, bioinfornatics wrote:
On Thursday, 14 November 2013 at 12:01:04 UTC, Ali Çehreli
wrote:
On 11/13/2013 04:32 PM, bioinfornatics wrote:
On Tuesday, 19 November 2013 at 21:33:31 UTC, Adam D. Ruppe wrote:
On Tuesday, 19 November 2013 at 21:25:47 UTC, Dale Matthews
wrote:
Adam, do you recommend using a struct instead of a class?
Yes, I would use a struct instead of a class here. The key
question to ask in D is: do you need
On Tuesday, 19 November 2013 at 23:58:20 UTC, Andrea Fontana
wrote:
And, of course, struct are value type, class are reference type.
Yeah, true in general, though it is possible to have a struct be
very similar to a reference type. Consider:
struct WrappedClass {
Object obj;
/* and
Ali Çehreli:
That is a VLA.
That are currently not present in D. The most common and safe
alternatives in D are allocating the memory on the heap with
'new', or over-allocating on the stack a fixed size and then
slicing.
If the OP really wants to allocate on the stack, there is the
I try this
import std.traits : isSomeChar;
import std.typetuple: TypeTuple;
import std.stdio;
template CharEncodingType(Char)
{
// Get representation type
alias TypeTuple!(ubyte, ushort, uint) U;
// const and immutable storage classes
static if (is(Char ==
On Tuesday, 19 November 2013 at 12:53:50 UTC, bearophile wrote:
Craig Dillabaugh:
// Assume images are of the same dimensions. Result is
// saved in Out.
void add(T,U,V)(Image!T A, Image!U B, Image!V Out) {
...
}
Take a look at the out annotation in D.
Anyway, thanks to whoever
works as expected
import std.traits : isSomeChar;
import std.range: ElementEncodingType;
import std.stdio;
@safe pure nothrow
template CharEncodingType(Char)
{
alias ET = ElementEncodingType!Char;
static if (is (ET == char)) {
alias CharEncodingType = ubyte;
} else
On Tuesday, 19 November 2013 at 23:34:48 UTC, Ali Çehreli wrote:
On 11/19/2013 03:16 PM, Carlos wrote: Well in C I just
declared an array during execution with an array with a
multiplied variable for the size of the array.
Since I only need two spaces in the array for each line of
process it
On 11/20/2013 5:59 AM, Dale Matthews wrote:
class Vec3
{
bool opEquals()(auto ref const Vec3 v) const
You don't need to use 'ref' on parameters that are classes. Unlike C++,
D classes are already reference types, not value types. More like Java.
Structs, OTOH, are value types. With
So I'm reading this tut from Ali :)
And we I got to this part :
A code example. http://pastebin.com/ESeL7dfH
But I want to declare this functions print outside of the file
and call the file to be loaded by the compiler. So I can use the
same solution in various program without having to copy
I just readhow to do it down on the list of tuts.
I did : dmd primes.d ./prime.d, and done program ran perfectly
On Tuesday, 19 November 2013 at 19:31:41 UTC, bearophile wrote:
The clean design is to use std.typecons.Nullable:
Nullable!(string[]) func(string[] zz) {
I have found that Nullable is pretty much useless for this type
of usage, because it aliases itself to the underlying value, and
then any
On Wednesday, 20 November 2013 at 02:14:29 UTC, Carlos wrote:
But I want to declare this functions print outside of the
file and call the file to be loaded by the compiler. So I can
use the same solution in various program without having to copy
paste it to each one.
first way - put this
Like I said in the title, this is related to Windows. Basically,
I'm looking to put a command line together to keep things
consistent between Windows, OSX and Linux.
On OSX and Linux I would do -L-lLibraryName, but is there
something similar that one can do on Windows? Or do I have to add
On 11/19/2013 11:18 PM, Jeremy DeHaan wrote:
Like I said in the title, this is related to Windows. Basically, I'm
looking to put a command line together to keep things consistent between
Windows, OSX and Linux.
On OSX and Linux I would do -L-lLibraryName, but is there something
similar that one
58 matches
Mail list logo