--Philippe wrote::
ElementType acts on types. It takes a type and 'returns' (compiles to,
actually) another type. You need to give it typeof(listR).
Then, as ElementType!(typeof(listR)) is a type, you cannot pass it to
writeln. Use .stringof to go from the type to a string representation
of its
Hello,
I get this error message:
Not the start of the UTF-8 sequence
without any other comment module name or whatnot.
This happens when I just added toString to the following struct, and used it:
struct Node {
// Note: level is equal to the number of chars up to this node.
spir Wrote:
Hello,
I get this error message:
Not the start of the UTF-8 sequence
without any other comment module name or whatnot.
This happens when I just added toString to the following struct, and used it:
struct Node {
// Note: level is equal to the number of
On 04/06/2011 11:53 AM, Kagamin wrote:
spir Wrote:
Hello,
I get this error message:
Not the start of the UTF-8 sequence
without any other comment module name or whatnot.
This happens when I just added toString to the following struct, and used it:
struct Node {
//
Hi,
I'm playing around with template alias parameters. At the moment I'm
considering the following simple code:
struct A
{};
struct B( T )
{
T t;
};
struct C( alias T )
{
T t;
};
void main()
{
B!A a;
C!A b;
}
What exactly is the difference between a and b? Both seem to do the
On 06.04.2011 02:15, Steven Schveighoffer wrote:
On Tue, 05 Apr 2011 19:37:15 -0400, Caligo iteronve...@gmail.com wrote:
It's just frustrating, that's all. Writing thousands of lines of code
and having everything stop because of a compiler bug is just
frustrating.
I completely understand.
import std.functional;
void foo(int x, int y, int z)
{
}
alias curry!(foo, 1, 2, 3) bar;
Error: template instance curry!(foo,1,2,3) does not match template declaration
curry(alias fun,alias arg)
Shouldn't curry take a variable number of arguments and then check the length
of the arguments
Andrej Mitrovic Wrote:
Yes, I write a whole new function, but why do that when curry is there. Or so
I thought..
Oops: *Yes, I _can_ write a whole new function
Here's a basic implementation:
import std.stdio;
import std.traits;
import std.metastrings;
template count(T...)
{
enum count = T.length;
}
template curry(alias fun, args...)
{
static if (args.length (ParameterTypeTuple!fun).length)
{
static assert(0, Format!(Tried to pass
Crap, that is a horrible implementation, I didn't take into account
not binding all arguments. Be right back..
Ok, enjoy this monstrosity:
template count(T...)
{
enum count = T.length;
}
template myCurry(alias fun, args...)
{
static if (args.length (ParameterTypeTuple!fun).length)
{
static assert(0, Format!(Tried to pass %s arguments, max is %s.,
It's still wrong, the tuple is backwards. Haha, that's what I get for
not unittesting.
Andrej Mitrovic:
Here's a basic implementation:
I have some general comments:
- Currying and partial function application are not exactly the same thing. So
I am not sure the curry in std.functional is named correctly;
- Partial application is important in a language that wants to support
Wow, talk about enlightement. I think I've done it now:
import std.stdio;
import std.traits;
import std.metastrings;
template count(T...)
{
enum count = T.length;
}
template myCurry(alias fun, args...)
{
static if (args.length (ParameterTypeTuple!fun).length)
{
static
On 4/6/11, bearophile bearophileh...@lycos.com wrote:
- Currying and partial function application are not exactly the same thing.
So I am not sure the curry in std.functional is named correctly;
Maybe bind should be a better name. I'm not sure..
Andrej Mitrovic:
Maybe bind should be a better name. I'm not sure..
In Python there is something similar that's named partial:
http://docs.python.org/library/functools.html#functools.partial
Bye,
bearophile
Well this still hasn't solved my problem. Because I shouldn't bind
from left to right, but arbitrarily.
So ideally I would want this:
void foo(string str, int x, int y, string str2) { }
alias bind!(foo, null, 1, 2, null) twoStrings;
twoStrings(abc, def); - foo(abc, 1, 2, def);
I'm pretty
Given an array of strings std.string.join() returns a single string:
import std.string;
void main() {
string[] a1 = [hello, red];
string j1 = join(a1, ); // OK
}
But in a program I need an array of mutable arrays of chars. If I join the
arrays I get a mutable array of chars. But I
On 04/06/2011 05:13 PM, bearophile wrote:
Given an array of strings std.string.join() returns a single string:
import std.string;
void main() {
string[] a1 = [hello, red];
string j1 = join(a1, ); // OK
}
But in a program I need an array of mutable arrays of chars. If I
join
enuhtac Wrote:
Hi,
I'm playing around with template alias parameters. At the moment I'm
considering the following simple code:
struct A
{};
struct B( T )
{
T t;
};
struct C( alias T )
{
T t;
};
void main()
{
B!A a;
C!A b;
}
What exactly is the
20 matches
Mail list logo