www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Some tools for D

reply Downs <default_357-line yahoo.de> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here's a collection of useful, generic tools code that extends the D
language. Originally written for Phobos, it should be easily adaptable
to Tango.

Includes:
 * tools.tests: Some simple test functions for unittests,
	used throughout the package itself
 * tools.iter: Iterator templates, including some useful
	default iterators such as the classical
	map, reduce, filter and zip as well as concat
 * tools.mrv: Multiple Return Values implementation, consisting
	of a TupleStruct and a MultiVariableHolder based on
	pointers (I've posted this one before, I believe)
 * tools.ext: Combines tools.iter and tools.mrv into TSzip,
	a zip iterator using tuple structs. Also allows chaining of
	delegates. Example (identity function):
		chain~(int e) { return e*2; }~(int e) { return e/2; }
	Furthermore, a Loop template based on chain, ifIs and mustBe,
	which simplify testing for an object's type. Example:
		class A { } class B : A { } A foo=new B;
		// evaluates to true
		ifIs(foo, (B b) { return true; }, { return false; });
	Furthermoar, an Integers iterator, used like Integers[5..50].
 * tools.threadpool: A really simple threadpool class.
	Also allows distributed foreach over an iterator.

Do not be disturbed by the total lack of comments - most of it is fairly
straightforward code which I simply didn't see any need to annotate.
Have fun!
 --downs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGyx6EpEPJRr05fBERAls7AKCWtOA/gDafE8iwCOHOHhM2FayhgwCfaKSE
KoEYFlbXpQRGpCK+b8kiOBM=
=6EOM
-----END PGP SIGNATURE-----
Aug 21 2007
next sibling parent reply Jari-Matti =?ISO-8859-1?Q?M=E4kel=E4?= <jmjmak utu.fi.invalid> writes:
Downs wrote:

 -----BEGIN PGP SIGNED MESSAGE-----
...
 -----END PGP SIGNATURE-----
A bit OT, but since you started signing your messages, is the public key available somewhere? Could you send it e.g. to public key servers?
Aug 21 2007
parent reply Downs <default_357-line yahoo.de> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jari-Matti Mäkelä wrote:
 A bit OT, but since you started signing your messages, is the public key
 available somewhere? Could you send it e.g. to public key servers?
Eh, that was primarily because I happened upon a Thunderbird build with OpenPGP in, and it has signing switched on by default, so instead of bothering to find out how to disable it I decided to simply set it up and use it .. then in the course of that I found out how to disable it after all, but at that point I was already well into setting it up, so I just went on. Apart from that, public key is appended to the end of the message. Have fun! --downs - -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.4.7 (GNU/Linux) mQGiBEbGChkRBACp9HsvM/V547pwPTPWOmyFsb5eiGxa0XJxXWfx674urv1OGJ2D CYs3Gzw027guliMyllgiDwUrN6/t2OyHgqXm9DTa70NN8g/JHLNtbd1GXX7u1YpY GS3RSOjvwFiFx9QVC56oTItEUcz33JOQNyu7LpsRSCKj/4fOozN0XKTrzwCgmhLa vcSCpGCNOkgNPfN9PSKTcVUD/Amq0cy9qZJk82RcsU3YYnauXruWI337Ad1cWFhl lkxS8W9mRmmMt9uGOS5DZFEG2mgyy+P2JjL/6oL7C81yFg3SZn5tGRB8/vopImh4 SHGwX+MqlIh6VxDYRueLX5UTR8UyUa0iXaBfnBgN9FzFgGoARB8zacSrueNrmAiw 0HuHA/420b3yCR1DfQaQWYStNrjRt8HqrWvlgG+eEycrZ+YQMoLAAdyHN6njGTM2 4TSIUYSryvCjIiHAa5PgeenCkWXrJ7Lm07JPapN/1a7bPSsvV3Skfv0C/CExrTGD tcIZBNxTUUDjkzSdnRQQDGUpH6wJT++ujzodHWmR8C31qxKdXLQhX19fX18gPGRl ZmF1bHRfMzU3LWxpbmVAeWFob28uZGU+iF8EExECAB8FAkbGChkCGwMGCwkIBwMC BBUCCAMDFgIBAh4BAheAAAoJELqnbqfGfSTWAcAAnR/OK4gFOi6gCOoLX+CLOBC1 0ropAJ4g6yGkhvv5wATybQHBOJ/GJiotrLkCDQRGxgoZEAgAuazf6wRhnOZTav9j GJicNrrLBNKrH7Epz05kdAqzo6w9wfjWrjVPpwt8FMebrssTF+eu7CRACMs/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R9mXhFxgwBqoRO0yFF9AgQT9n+riISQQYEQIACQUCRsYK0wIbDAAK CRCkQ8lGvTl8Ec8VAKCashT1fPyKNrUaRHdpdve/n1eV/QCfcwdE+6ql87NXpdap sdc5e6etAIU= =1+cp - -----END PGP PUBLIC KEY BLOCK----- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGy0GopEPJRr05fBERAu/uAJ9xyU7pYKcGGSYPGQDtMfOlgxKHQQCfYKdA Rv/USrlm6JUJWuDmpcGhEJk= =6STY -----END PGP SIGNATURE-----
Aug 21 2007
parent reply Stephen Waits <steve waits.net> writes:
Downs wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
[snip]
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.7 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
 iD8DBQFGy0GopEPJRr05fBERAu/uAJ9xyU7pYKcGGSYPGQDtMfOlgxKHQQCfYKdA
 Rv/USrlm6JUJWuDmpcGhEJk=
 =6STY
 -----END PGP SIGNATURE-----
You might be interested in checking out S/MIME. --Steve
Aug 21 2007
parent =?ISO-8859-1?Q?St=E9phan_Kochen?= <stephan kochen.nl> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stephen Waits schreef:
 You might be interested in checking out S/MIME.
That came out of nowhere. PGP is more popular among communities because it uses a trust system based on a web trust. (This signature belongs to that person because: I've met this person and trust him, OR 'x' other people I know trust him.) S/MIME is more popular in corporations because it's certificates are based on a hierarchy of certificate authorities. (This signature belongs to that person, because the certificate was issued by Company, and Company's signature was in turn signed by Thawte, for example.) Not having any kind of authority works well for community projects. It's worth a discussion in itself, but I don't see a reason to have that here. I personally use PGP, and think it works well enough in Thunderbird with the Enigmail extension. - -- Stéphan -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGzBfvcFUq0gzqDwQRAgQnAJsE9MV8iIDqSYsoNQG3u2fuXpYy4wCZAZgU autiV8vmEcN4MNJ6KGQMlX4= =38kD -----END PGP SIGNATURE-----
Aug 22 2007
prev sibling next sibling parent reply Downs <default_357-line yahoo.de> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here's a patch that introduces a vastly simplified map/reduce/filter
syntax for small functions. Also allows you to use functions instead of
delegates.

Example:
* Previous version:
  * Integers[0..10]~
    tszip(Integers[10..20])~
    map((TupleStruct!(Pair!(int)) ts) {
      return ts.values[0]*ts.values[1];
    })~
    reduce((ref int a, int b) { a+=b; })
* Patched Version:
  * Integers[0..10]~
    tszip(Integers[10..20])~
    maps!("_.values[0]*_.values[1]")~
    reduces!("+=_")

 --downs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGzVFxpEPJRr05fBERAhJTAJ4tUJ1c/3OrEvQ+0kVtea8oCGufYgCfRSiY
wAnW+sjfL3tRkb50urH0luM=
=G/82
-----END PGP SIGNATURE-----
Aug 23 2007
next sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Downs wrote from an hour in the future:
 ...Here's a patch that introduces a vastly simplified map/reduce/filter
 syntax for small functions. Also allows you to use functions instead of
 delegates.
Downs, man, come back from the future and hang out with the rest of us here. Or at least give us some stock market tips. --bb
Aug 23 2007
parent reply Downs <default_357-line yahoo.de> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bill Baxter wrote:
 Downs wrote from an hour in the future:
 ...Here's a patch that introduces a vastly simplified map/reduce/filter
 syntax for small functions. Also allows you to use functions instead of
 delegates.
Downs, man, come back from the future and hang out with the rest of us here. Or at least give us some stock market tips. --bb
Sorry, my system clock was set to local time. It should be fixed now. Apropos, is it really a good idea for the news server to trust the client with the message time? --downs -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGzUy4pEPJRr05fBERApNdAJ45FzsAOlFRRiFRR1ELTvBMoNyaZACgokxy 9DOYx+2rtIFz/2PvqpRrJ+E= =SSye -----END PGP SIGNATURE-----
Aug 23 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Downs wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 Bill Baxter wrote:
 Downs wrote from an hour in the future:
 ...Here's a patch that introduces a vastly simplified map/reduce/filter
 syntax for small functions. Also allows you to use functions instead of
 delegates.
Downs, man, come back from the future and hang out with the rest of us here. Or at least give us some stock market tips. --bb
Sorry, my system clock was set to local time. It should be fixed now. Apropos, is it really a good idea for the news server to trust the client with the message time? --downs
I'm not sure it's the server's fault. Actually I just discovered thunderbird has a way to sort by "order received" which uses the message number rather than date. Also the messages all have a header like: NNTP-Posting-Date: Thu, 23 Aug 2007 09:01:01 +0000 (UTC) in addition to the listed date. So maybe it's more a newsreader issue. --bb
Aug 23 2007
parent Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Bill Baxter wrote:
 Downs wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 Bill Baxter wrote:
 Downs wrote from an hour in the future:
 ...Here's a patch that introduces a vastly simplified map/reduce/filter
 syntax for small functions. Also allows you to use functions instead of
 delegates.
Downs, man, come back from the future and hang out with the rest of us here. Or at least give us some stock market tips. --bb
Sorry, my system clock was set to local time. It should be fixed now. Apropos, is it really a good idea for the news server to trust the client with the message time? --downs
I'm not sure it's the server's fault. Actually I just discovered thunderbird has a way to sort by "order received" which uses the message number rather than date. Also the messages all have a header like: NNTP-Posting-Date: Thu, 23 Aug 2007 09:01:01 +0000 (UTC) in addition to the listed date. So maybe it's more a newsreader issue. --bb
Using the threaded view also makes the conversation appear in the right order. -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Aug 23 2007
prev sibling parent reply Downs <default_357-line yahoo.de> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I made a rather stupid mistake in ifIs that would make the program crash
hard. Sorry. Here's the patch for the fixed version against the original
post (also includes the other patch).
Also, just to make it clear - I don't think any of this stuff is
copyrightable on account of being too trivial. So take what you need.
 --downs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGzVhSpEPJRr05fBERAv4TAJ9phEOvzG1xyozrvdIrexijW8eb/wCeKp3t
EwG2Gr9+9qLD9TlavbeEOT4=
=JW2B
-----END PGP SIGNATURE-----
Aug 23 2007
parent reply BCS <ao pathlink.com> writes:
Reply to Downs,

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 I made a rather stupid mistake in ifIs that would make the program
 crash
 hard. Sorry. Here's the patch for the fixed version against the
 original
 post (also includes the other patch).
 Also, just to make it clear - I don't think any of this stuff is
 copyrightable on account of being too trivial. So take what you need.
 --downs
Woudl you like to put this in scrapple?
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.7 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
 iD8DBQFGzVhSpEPJRr05fBERAv4TAJ9phEOvzG1xyozrvdIrexijW8eb/wCeKp3t
 EwG2Gr9+9qLD9TlavbeEOT4=
 =JW2B
-----END PGP SIGNATURE-----
Aug 23 2007
parent reply Downs <default_357-line yahoo.de> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

BCS wrote:
 Reply to Downs,
 
 I made a rather stupid mistake in ifIs that would make the program
 crash
 hard. Sorry. Here's the patch for the fixed version against the
 original
 post (also includes the other patch).
 Also, just to make it clear - I don't think any of this stuff is
 copyrightable on account of being too trivial. So take what you need.
 --downs
 
 Woudl you like to put this in scrapple?
Sure, thanks for the offer :D --downs -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGzaWppEPJRr05fBERAoFGAJwNaRRmwe1JTuFPAGwA108rlzzY2wCfbdfF H1ZxIDWM8/49R6OlPdkzoAk= =hgIg -----END PGP SIGNATURE-----
Aug 23 2007
parent reply BCS <ao pathlink.com> writes:
Reply to Downs,

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 BCS wrote:
 
 Reply to Downs,
 
 I made a rather stupid mistake in ifIs that would make the program
 crash
 hard. Sorry. Here's the patch for the fixed version against the
 original
 post (also includes the other patch).
 Also, just to make it clear - I don't think any of this stuff is
 copyrightable on account of being too trivial. So take what you need.
 --downs
 Woudl you like to put this in scrapple?
 
Sure, thanks for the offer :
sned me a dsource username and I'll add you as a dev.
Aug 23 2007
parent reply Downs <default_357-line yahoo.de> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

BCS wrote:
 Reply to Downs,
 
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 BCS wrote:

 Reply to Downs,

 I made a rather stupid mistake in ifIs that would make the program
 crash
 hard. Sorry. Here's the patch for the fixed version against the
 original
 post (also includes the other patch).
 Also, just to make it clear - I don't think any of this stuff is
 copyrightable on account of being too trivial. So take what you need.
 --downs
 Woudl you like to put this in scrapple?
Sure, thanks for the offer :
sned me a dsource username and I'll add you as a dev.
Thanks; I'm FeepingCreature :) --downs -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGzykYpEPJRr05fBERAmkTAJ9YDk6ZcI9Lv4GHr1Nq2NJEP3Y5egCeMP5W nXF06nFSUm5TpyeJlhLl8wk= =TgL9 -----END PGP SIGNATURE-----
Aug 24 2007
parent BCS <ao pathlink.com> writes:
Reply to Downs,


 send me a dsource username and I'll add you as a dev.
 
Thanks; I'm FeepingCreature :) --downs
your in, have fun
Aug 25 2007
prev sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Downs wrote:
 Here's a collection of useful, generic tools code that extends the D
 language. Originally written for Phobos, it should be easily adaptable
 to Tango.
Thanks for making these tools available. But I strongly suggest posting them on http://www.dsource.org, which is designed for hosting projects, and then post an announcement here that links to them. The newsgroups make for a terrible source code repository.
Aug 25 2007