Re: Higher-order functions?

2012-04-11 Thread Xan
Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And call it with: IO.writeLine(add: .. someprocedure(2, 3, { a, b = a + b }))

Re: Higher-order functions?

2012-04-11 Thread Jacob Carlborg
On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And call it with: IO.writeLine(add: .. someprocedure(2, 3, { a, b = a + b

Re: Higher-order functions?

2012-04-11 Thread Xan
On Wednesday, 11 April 2012 at 09:17:12 UTC, Jacob Carlborg wrote: On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And

Re: Higher-order functions?

2012-04-11 Thread Timon Gehr
On 04/11/2012 11:37 AM, Xan wrote: On Wednesday, 11 April 2012 at 09:17:12 UTC, Jacob Carlborg wrote: On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int:

Re: Higher-order functions?

2012-04-11 Thread Xan
On Wednesday, 11 April 2012 at 09:43:27 UTC, Timon Gehr wrote: On 04/11/2012 11:37 AM, Xan wrote: On Wednesday, 11 April 2012 at 09:17:12 UTC, Jacob Carlborg wrote: On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in

Re: Higher-order functions?

2012-04-11 Thread Mirko Pilger
What is the error? e.g. try this: auto someprocedure (int a, int b, int delegate (int, int) f)

Re: Higher-order functions?

2012-04-11 Thread Xan
On Wednesday, 11 April 2012 at 10:14:21 UTC, Mirko Pilger wrote: What is the error? e.g. try this: auto someprocedure (int a, int b, int delegate (int, int) f) I receive the same error

Re: Higher-order functions?

2012-04-11 Thread Timon Gehr
On 04/11/2012 11:51 AM, Xan wrote: On Wednesday, 11 April 2012 at 09:43:27 UTC, Timon Gehr wrote: On 04/11/2012 11:37 AM, Xan wrote: On Wednesday, 11 April 2012 at 09:17:12 UTC, Jacob Carlborg wrote: On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest

Re: Higher-order functions?

2012-04-11 Thread Xan
Apparently your compiler does not support parameter type deduction yet. void main () { writeln(add: , someprocedure(2, 3, (int a, int b) { return a + b; })); writeln(multiply: , someprocedure(2, 3, (int a, int b) { return a * b; })); } Yes, now it works! Thanks,

Passing function as values and returning functions

2012-04-11 Thread Xan
Hi, Following the thread of Higher-order functions, how can I do to pass a function as a parameter and return a function. That is a something like: import std.functional, std.stdio; int f (int a) { return 2*a; } int delegate (int) g(int function(int a) p) { return p; } void main()

Re: Passing function as values and returning functions

2012-04-11 Thread Jacob Carlborg
On 2012-04-11 13:10, Xan wrote: Hi, Following the thread of Higher-order functions, how can I do to pass a function as a parameter and return a function. That is a something like: import std.functional, std.stdio; int f (int a) { return 2*a; } int delegate (int) g(int function(int a) p) {

Re: Passing function as values and returning functions

2012-04-11 Thread Xan
On Wednesday, 11 April 2012 at 11:59:14 UTC, Jacob Carlborg wrote: On 2012-04-11 13:10, Xan wrote: Hi, Following the thread of Higher-order functions, how can I do to pass a function as a parameter and return a function. That is a something like: import std.functional, std.stdio; int f

Re: Passing function as values and returning functions

2012-04-11 Thread Steven Schveighoffer
On Wed, 11 Apr 2012 08:08:44 -0400, Xan xancor...@gmail.com wrote: On Wednesday, 11 April 2012 at 11:59:14 UTC, Jacob Carlborg wrote: Use delegate or function both for the argument type and return type. How to do that? int function(int) g(int function(int a) p) { return p; } Should do

stdout redirect

2012-04-11 Thread Andrea Fontana
How can I redirect stdout / stderr to file (from D not shell)?

Re: Passing function as values and returning functions

2012-04-11 Thread Xan
On Wednesday, 11 April 2012 at 12:19:06 UTC, Steven Schveighoffer wrote: On Wed, 11 Apr 2012 08:08:44 -0400, Xan xancor...@gmail.com wrote: On Wednesday, 11 April 2012 at 11:59:14 UTC, Jacob Carlborg wrote: Use delegate or function both for the argument type and return type. How to do

Re: Passing function as values and returning functions

2012-04-11 Thread Steven Schveighoffer
On Wed, 11 Apr 2012 08:53:00 -0400, Xan xancor...@gmail.com wrote: Thanks, Steve, but another problem: [snip] void main() { |___writeln(g(f)(1)); } writeln(g(f)(1)); Unlike C, you *must* take the address of a function symbol to get a function pointer. -Steve

Re: stdout redirect

2012-04-11 Thread Andrea Fontana
On Wednesday, 11 April 2012 at 12:46:30 UTC, Andrea Fontana wrote: How can I redirect stdout / stderr to file (from D not shell)? Self-reply: It works using std.c way: import std.cstream; std.c.stdio.freopen(args[4].ptr, w+, dout.file); std.c.stdio.freopen(args[4].ptr, w+, derr.file);

Re: D Dll injection problem

2012-04-11 Thread maarten van damme
I went ahead and went back to as far as 2.045 and I still couldn't get a working dll. This would suggest something is wrong with my dll injection code but I've tested with a few other random dll's and that appears to work. according to my debugger the problem is an access violation while executing

Re: D Dll injection problem

2012-04-11 Thread Kagamin
On Wednesday, 11 April 2012 at 13:26:23 UTC, maarten van damme wrote: I went ahead and went back to as far as 2.045 and I still couldn't get a working dll. This would suggest something is wrong with my dll injection code but I've tested with a few other random dll's and that appears to work.

Re: D Dll injection problem

2012-04-11 Thread Kagamin
On Wednesday, 11 April 2012 at 13:26:23 UTC, maarten van damme wrote: the code I use for injecting is /** * injectDLL injects a dll in a given process using the CreateRemoteThread function. * * arguments: * HANDLE proc = A HANDLE to the process * string dllName = A string containting the

Re: stdout redirect

2012-04-11 Thread Stefan
On Wednesday, 11 April 2012 at 13:00:45 UTC, Andrea Fontana wrote: On Wednesday, 11 April 2012 at 12:46:30 UTC, Andrea Fontana wrote: How can I redirect stdout / stderr to file (from D not shell)? Self-reply: It works using std.c way: import std.cstream; std.c.stdio.freopen(args[4].ptr, w+,

Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.

2012-04-11 Thread vmars316
On Tuesday, 10 April 2012 at 22:31:44 UTC, Andrej Mitrovic wrote: On 4/10/12, vmars316 vmars...@live.com wrote: On Tuesday, 10 April 2012 at 20:07:41 UTC, Andrej Mitrovic You can use the zip download: https://github.com/Rayerd/dfl/zipball/master A couple years ago i learned HotBasic. An

Re: Higher-order functions?

2012-04-11 Thread Jonas H.
Wow, thanks for all the answers! Seems to be a great community here. What do you guys think about adding the term anonymous functions to the frontpage and features page? I think that one's a lot more comman than delegates (even if it's not exactly the same thing).

Re: Higher-order functions?

2012-04-11 Thread H. S. Teoh
On Wed, Apr 11, 2012 at 07:29:20PM +0200, Jonas H. wrote: Wow, thanks for all the answers! Seems to be a great community here. Welcome to the community! :-) What do you guys think about adding the term anonymous functions to the frontpage and features page? I think that one's a lot more

Re: Passing function as values and returning functions

2012-04-11 Thread Xan
On Wednesday, 11 April 2012 at 13:04:01 UTC, Steven Schveighoffer wrote: On Wed, 11 Apr 2012 08:53:00 -0400, Xan xancor...@gmail.com wrote: Thanks, Steve, but another problem: [snip] void main() { |___writeln(g(f)(1)); } writeln(g(f)(1)); Unlike C, you *must* take the address of a

Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.

2012-04-11 Thread vmars316
On Tuesday, 10 April 2012 at 22:31:44 UTC, Andrej Mitrovic wrote: You can use the zip download: https://github.com/Rayerd/dfl/zipball/master ...ok, i downloaded PortableGit-1.7.10-preview20120409.7z and i put it here: C:\D\dmd2\windows\Dfl\import\dfl\win32\dflexe I am not sure if i need GTK

Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.

2012-04-11 Thread Andrej Mitrovic
On 4/11/12, vmars316 vmars...@live.com wrote: How do I build the dfl.lib (DFL_LIB DFL_IMPORT), Didn't you get this message: msysgit: $ git clone https://github.com/Rayerd/dfl.git cmd.exe (set these paths to where DM and DMD are installed) $ set dmc_path=C:\dm $ set dmd_path=C:\DMD\dmd2 $ cd

Name of files causes error. Why?

2012-04-11 Thread Xan
Hi, With helloworld program named with score or underscore, I receive the following __annoying__ error: $ gdmd-4.6 hola-temp.d hola-temp.d: Error: module hola-temp has non-identifier characters in filename, use module declaration instead Why? Can someone fix it. It's really annoying

Re: Name of files causes error. Why?

2012-04-11 Thread Andrej Mitrovic
On 4/11/12, Xan xancor...@gmail.com wrote: With helloworld program named with score or underscore, I receive the following __annoying__ error: Underscores should work fine (and they do for me). Scores (or dashes) can't work because an indentifier with a dash is not a valid identifier, so a

Re: Name of files causes error. Why?

2012-04-11 Thread Steven Schveighoffer
On Wed, 11 Apr 2012 15:33:56 -0400, Xan xancor...@gmail.com wrote: Hi, With helloworld program named with score or underscore, I receive the following __annoying__ error: $ gdmd-4.6 hola-temp.d hola-temp.d: Error: module hola-temp has non-identifier characters in filename, use module

Re: Multiple %s format specifiers with a single argument

2012-04-11 Thread James Miller
* Mike Parker aldac...@gmail.com [2012-04-10 18:46:42 +0900]: On 4/10/2012 3:43 AM, Ali Çehreli wrote: On 04/09/2012 10:35 AM, Andrej Mitrovic wrote: On 4/9/12, Jonathan M Davisjmdavisp...@gmx.com wrote: Posix positional arguments seem to work for writefln but not format for whatever reason.

Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.

2012-04-11 Thread vmars316
On Wednesday, 11 April 2012 at 18:39:40 UTC, Andrej Mitrovic wrote: On 4/11/12, vmars316 vmars...@live.com wrote: Didn't you get this message: Andrej, Yes, I got it. But lost track of it, sorry. Anyways, yahoo, I am almost there. I now have a dfl.lib . I ran following (~myForm-compile-2.bat) :

Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.

2012-04-11 Thread Andrej Mitrovic
On 4/12/12, vmars316 vmars...@live.com wrote: What is looking for? *import* something? Remove the space between '-I' and the import path.