Re: A little of coordination for Rosettacode

2014-08-14 Thread bearophile via Digitalmars-d-learn
safety0ff: Here's a candidate for http://rosettacode.org/wiki/Extensible_prime_generator#D in case it is preferred to the existing entry: http://dpaste.dzfl.pl/43735da3f1d1 I was away. I have added your nice code with some small changes as an alternative faster version. I think you have

Re: A little of coordination for Rosettacode

2014-08-07 Thread safety0ff via Digitalmars-d-learn
On Tuesday, 12 February 2013 at 01:07:35 UTC, bearophile wrote: In practice at the moment I am maintaining all the D entries of Rosettacode. Here's a candidate for http://rosettacode.org/wiki/Extensible_prime_generator#D in case it is preferred to the existing entry:

Re: A little of coordination for Rosettacode

2014-07-31 Thread safety0ff via Digitalmars-d-learn
On Tuesday, 12 February 2013 at 01:07:35 UTC, bearophile wrote: In practice at the moment I am maintaining all the D entries of Rosettacode. I modified the Hamming numbers code in a personal exercise. It now uses considerably less memory but is slower. I've posted the code here in case it

Re: A little of coordination for Rosettacode

2014-07-31 Thread bearophile via Digitalmars-d-learn
safety0ff: I modified the Hamming numbers code in a personal exercise. It now uses considerably less memory but is slower. I've posted the code here in case it is of use: http://dpaste.dzfl.pl/3990023e5577 For a single n, n = 350_000_000: Alternative version 2: 13.4s and ~5480 MB of ram My

Re: A little of coordination for Rosettacode

2014-02-26 Thread bearophile
Ali Çehreli: Improve at will! :p I will mostly just uniform its formatting to all the other Rosettacode entries, shorten the lines to 72 chars, etc. synchronized { // Switch to the next printer printers = printers[1..$];

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
On Wednesday, 26 February 2014 at 11:24:58 UTC, bearophile wrote: Ali Çehreli: synchronized { // Switch to the next printer printers = printers[1..$]; } This doesn't work: printers.popFront(); Yes, because

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
I forgot to note that both synchronized {} blocks should also be synchronizing on the same mutex. Right now it's two different critical sections, so a race is still possible, i.e. while one thread is printing the other may be removing the first printer. Run the code several times and you'll no

Re: A little of coordination for Rosettacode

2014-02-26 Thread bearophile
Stanislav Blinov: You'd also have to synchronize access to id member, I forgot to note that both synchronized {} blocks should also be synchronizing on the same mutex. The mutex could be emulated with a shared bool and std.atomic.cas(). That would get rid of synchronized{} blocks and

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
On Wednesday, 26 February 2014 at 12:58:26 UTC, bearophile wrote: If you have bug fixes, or improvements, it's better to do them right there. Of if you don't want to register on that site, you can put the modified version in dpaste, and I'll upload it on Rosettacode. Here are some

Re: A little of coordination for Rosettacode

2014-02-26 Thread Ali Çehreli
On 02/26/2014 03:24 AM, bearophile wrote: Ali Çehreli: Improve at will! :p I will mostly just uniform its formatting to all the other Rosettacode entries, shorten the lines to 72 chars, etc. synchronized { // Switch to the next printer

Re: A little of coordination for Rosettacode

2014-02-26 Thread bearophile
Ali Çehreli: And I am not sure why the slicing syntax works because the 'printers' member is still shared then. Probably it's a known D implementation fault meant to be eventually fixed. - Stanislav Blinov: Here are some improvements: http://dpaste.dzfl.pl/6430488f3d07

Re: A little of coordination for Rosettacode

2014-02-26 Thread Ali Çehreli
On 02/26/2014 04:46 AM, Stanislav Blinov wrote: I forgot to note that both synchronized {} blocks should also be synchronizing on the same mutex. Oh, that's a good one! :) Run the code several times and you'll no doubt stumble upon it. But I had inserted that Sleep() in there. Isn't that

Re: A little of coordination for Rosettacode

2014-02-26 Thread Ali Çehreli
On 02/26/2014 06:58 AM, bearophile wrote: Updated the site http://rosettacode.org/wiki/Rendezvous#D Thanks for posting the problem to begin with. I've learned a lot. Ali

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
On Wednesday, 26 February 2014 at 14:54:05 UTC, Ali Çehreli wrote: On 02/26/2014 03:24 AM, bearophile wrote: Ali Çehreli: Improve at will! :p I will mostly just uniform its formatting to all the other Rosettacode entries, shorten the lines to 72 chars, etc. synchronized

Re: A little of coordination for Rosettacode

2014-02-26 Thread bearophile
Stanislav Blinov: The whole 'shared' concept being incomplete in the language is a shame. Hopefully things will get better in the near future. As for slicing syntax for shared arrays, personally I think it should be disallowed, just like operators for shared scalars. But that would mean

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
Thank you for posting the code. However, I think there might be a subtle bug with my synchronization on bools, but I need to comtemplate on it some more to be sure :) On Wednesday, 26 February 2014 at 15:52:24 UTC, bearophile wrote: Stanislav Blinov: Oh, there is still much to discuss on

Re: A little of coordination for Rosettacode

2014-02-25 Thread bearophile
Is someone willing to write a D entry for this? http://rosettacode.org/wiki/Rendezvous Bye, bearophile

Re: A little of coordination for Rosettacode

2014-02-25 Thread Ali Çehreli
On 02/25/2014 03:48 PM, bearophile wrote: Is someone willing to write a D entry for this? http://rosettacode.org/wiki/Rendezvous Bye, bearophile I think the following satisfies the requirements. Improve at will! :p import std.stdio; import std.exception; import std.array; import

Re: A little of coordination for Rosettacode

2014-01-16 Thread bearophile
qznc: This sounds somewhat paradox to me. How can a new feature have a regression? A regression means it has worked before, but new feature did not exist before. Regressions on older betas; or to see if using the new features breaks other apparently unrelated parts of old code. In

Re: A little of coordination for Rosettacode

2014-01-15 Thread qznc
I just made some scripts [0] to download and compile all D examples from Rosettacode. From 186 of 716 examples fail to compile [1]. Some for trivial reasons like not wrapped into a main function or a missing import. Some require SDL or Tango or other third-party libraries. My ultimate goal

Re: A little of coordination for Rosettacode

2014-01-15 Thread bearophile
Brad Roberts: I think this is a mistake. They should compile with a released compiler. Why? And why do you think that outweighs the several advantages of having entries compilable only with the latest beta compiler? (Currently there are 40-50 entries that don't compile with the released

Re: A little of coordination for Rosettacode

2014-01-15 Thread Brad Roberts
On 1/15/14 4:42 PM, bearophile wrote: Brad Roberts: I think this is a mistake. They should compile with a released compiler. Why? And why do you think that outweighs the several advantages of having entries compilable only with the latest beta compiler? (Currently there are 40-50 entries

Re: A little of coordination for Rosettacode

2014-01-15 Thread bearophile
Brad Roberts: Requiring that users of the code in resottacode be using bleeding edge, unreleased, compilers is a disservice to those users. Typical users will not and should not need to use anything other than a released compiler. Some of the rosettacode usages/purposes are: - Trying new

Re: A little of coordination for Rosettacode

2014-01-15 Thread bearophile
qznc: [0] https://bitbucket.org/qznc/rosetta/src/da12e3673b0d/compile_all/?at=master [1] https://gist.github.com/qznc/9ba4b0e78abfc35d4694 Few of the tasks of your list were never updated to D2/Phobos, and they should be updated. Among the ones that are updated, I have found five that

Re: A little of coordination for Rosettacode

2014-01-15 Thread bearophile
arithmetic_evaluation.d balanced_ternary.d combinations_with_repetitions1.d k_means_plus_plus_clustering.d names_to_numbers.d or number_names.d I have fixed them. This is the problem in array, already in Bugzilla, I think it's a kind of regression: import std.array: array; immutable foo =

Re: A little of coordination for Rosettacode

2014-01-15 Thread qznc
On Thursday, 16 January 2014 at 01:11:23 UTC, bearophile wrote: - To test the compiler betas to see if they have regressions if you try to use the new features. This sounds somewhat paradox to me. How can a new feature have a regression? A regression means it has worked before, but new

Re: A little of coordination for Rosettacode

2013-11-25 Thread bearophile
This D1 entry needs an update: http://rosettacode.org/wiki/Metered_concurrency#D Is someone willing to update it? import std.stdio, core.thread, std.c.time; class Semaphore { private int lockCnt, maxCnt; this(in int count) { maxCnt = lockCnt = count; } void acquire()

Re: A little of coordination for Rosettacode

2013-08-31 Thread bearophile
Jos van Uden: It's an old task (from 2007). The task description was changed after the D entries were made. Yes, there are about 63 Rosettacode tasks that I have not yet updated: accumulator_factory.d address_of_a_variable.d animation.d boolean_values.d

Re: A little of coordination for Rosettacode

2013-08-30 Thread bearophile
I have added a D entry for the Go Fish game: http://rosettacode.org/wiki/Go_Fish#D I don't know the Go Fish game, so I am not sure this code is correct. Is some of you able and willing to test its play a bit? (This D entry is very Python-style because it's a translation of the Python entry,

Re: A little of coordination for Rosettacode

2013-08-30 Thread maarten van damme
the entry : http://rosettacode.org/wiki/File_IO is wrong because as stated by the asignment : In this task, the job is to create a file called output.txt, and place in it the contents of the file input.txt, *via an intermediate variable.*** * * there is no intermediate variable; I don't know if

Re: A little of coordination for Rosettacode

2013-08-30 Thread Adam D. Ruppe
On Saturday, 31 August 2013 at 01:42:43 UTC, bearophile wrote: I have added a D entry for the Go Fish game: hmm there's too much text output, it makes following the game hard, and seeing what the computer drew means you can cheat! But I think it plays correctly, I was able to finish a game.

Re: A little of coordination for Rosettacode

2013-08-30 Thread Jos van Uden
On 31-8-2013 4:08, maarten van damme wrote: the entry : http://rosettacode.org/wiki/File_IO is wrong because as stated by the asignment : In this task, the job is to create a file called output.txt, and place in it the contents of the file input.txt, /via an intermediate variable./// / / there

Re: A little of coordination for Rosettacode

2013-07-25 Thread bearophile
This D entry uses Tango, but it should also show a version for Phobos: http://rosettacode.org/wiki/Rosetta_Code/Count_examples#D Bye, bearophile

Re: A little of coordination for Rosettacode

2013-07-25 Thread bearophile
This D entry uses Tango, but it should also show a version for Phobos: http://rosettacode.org/wiki/Rosetta_Code/Count_examples#D Two versions The Mathematica solution is short: TaskList = Flatten[ Import[http://rosettacode.org/wiki/Category:Programming_Tasks;, Data][[1, 1]]];

Re: A little of coordination for Rosettacode

2013-07-21 Thread bearophile
Now this D entry works again: http://rosettacode.org/wiki/S-Expressions#D Probably it can be written without explicit indexes, only using txt.front, txt.popFrontN, txt.find, etc. Do you want to produce such modified version? This simple task shows well why a parser combinators like Parsec

Re: A little of coordination for Rosettacode

2013-07-16 Thread bearophile
This entry has stopped working since lot of time: http://rosettacode.org/wiki/MD5/Implementation#D This is an improved version, but help is welcome: http://codepad.org/g4RBio8E Bye, bearophile

Re: A little of coordination for Rosettacode

2013-07-16 Thread bearophile
http://codepad.org/g4RBio8E this line: .replace(TT, 0x ~ text(T(n), 16)); Needs to be: .replace(TT, 0x ~ to!string(T(n), 16)); But the code in that link is all wrong because it needs all the code from std.md5 to work. And even then I don't know where Decode() is. Bye, bearophile

Re: A little of coordination for Rosettacode

2013-07-16 Thread bearophile
But the code in that link is all wrong because it needs all the code from std.md5 to work. And even then I don't know where Decode() is. OK, the code now works :-) Bye, bearophile

Re: A little of coordination for Rosettacode

2013-07-16 Thread bearophile
OK, the code now works :-) And the results are a bit hilarious: ...md5_implementation5_dmd md5 digest() = D41D8CD98F00B204E9800998ECF8427E zmd5 digest() = D41D8CD98F00B204E9800998ECF8427E Test performance / message size 200MBytes digest(data) = F083432AB71F6177A8EC2CA5157F7B83 std.md5:

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-07-03 Thread Marco Leise
Am Sat, 22 Jun 2013 23:27:00 +0200 schrieb bearophile bearophileh...@lycos.com: Ali Çehreli: The code compiles under 32-bit (e.g. with the -m32 compiler switch) where size_t is an alias of uint. Oh, I see. I compile most of the code on a 32 bit system. I asked Walter to warn d

Re: A little of coordination for Rosettacode

2013-06-23 Thread bearophile
Adam D. Ruppe: code: http://arsdnet.net/dcode/rpc-example.d library: https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/rpc.d It's online: http://rosettacode.org/wiki/Distributed_programming#D Bye, bearophile

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-23 Thread Brian Rogoff
On Saturday, 22 June 2013 at 21:27:01 UTC, bearophile wrote: Ali Çehreli: The code compiles under 32-bit (e.g. with the -m32 compiler switch) where size_t is an alias of uint. Thanks, Ali! I'm always compiling on 64 bit systems; I'll add the 32 bit switch to my diagnostic approach now.

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread Brian Rogoff
On Saturday, 16 February 2013 at 11:30:00 UTC, Jos van Uden wrote: On 16-2-2013 8:58, qznc wrote: On Saturday, 16 February 2013 at 06:58:01 UTC, qznc wrote: On Saturday, 16 February 2013 at 02:23:42 UTC, Jos van Uden wrote: On 5-2-2013 20:45, Jos van Uden wrote: By the way, I think 'Qznc'

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread bearophile
Brian Rogoff: The current D code for Dining philosophers does not compile with dmd v2.063.2, the error message being dining.d(34): Error: cannot uniquely infer foreach argument types I try to keep the D entries on Rosettacode updated, but every dmd release breaks tons of code, and

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread Ali Çehreli
On 06/22/2013 11:53 AM, Brian Rogoff wrote: The current D code for Dining philosophers does not compile with dmd v2.063.2, the error message being dining.d(34): Error: cannot uniquely infer foreach argument types The code compiles under 32-bit (e.g. with the -m32 compiler switch) where

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread bearophile
Ali Çehreli: The code compiles under 32-bit (e.g. with the -m32 compiler switch) where size_t is an alias of uint. Oh, I see. I compile most of the code on a 32 bit system. I asked Walter to warn d programmers against such mistakes, and Walter closed it down. Someone else has opened the ER

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread bearophile
I asked Walter to warn d programmers against such mistakes, and Walter closed it down. Someone else has opened the ER again... I meant this: http://d.puremagic.com/issues/show_bug.cgi?id=5063 In the meantime I have fixed the Rosettacode entry. Bye, bearophile

Re: A little of coordination for Rosettacode

2013-06-18 Thread Simen Kjaeraas
On 2013-06-18, 05:00, bearophile wrote: With your code I have found a dmd compiler bug, are you able and willing to further reduce this? Tried this with 2.063.2, and there are three errors in the code - deserializeInto should return its buffer, the switch on line 19 needs a default: case,

Re: A little of coordination for Rosettacode

2013-06-18 Thread bearophile
Simen Kjaeraas: Tried this with 2.063.2, and there are three errors in the code - deserializeInto should return its buffer, the switch on line 19 needs a default: case, and deserializeInto tries to modify its non-buffer argument (which in this case is a const string. None of these seem to be

Re: A little of coordination for Rosettacode

2013-06-18 Thread Adam D. Ruppe
On Tuesday, 18 June 2013 at 09:22:05 UTC, bearophile wrote: third is the one that triggers a crash of my DMD version. I am keeping my compiler updated, I have compiled it yesterday, and it crashes after giving the error: test.d(28): Error: cannot modify const expression s Now I don't know if

Re: A little of coordination for Rosettacode

2013-06-18 Thread bearophile
Adam D. Ruppe: I can't reproduce the compiler crash you saw though. Thank you. Then it's somehow just my compiler... Bye, bearophile

Re: A little of coordination for Rosettacode

2013-06-17 Thread bearophile
Adam D. Ruppe: and win the code golf every time! :P Some Rosettacode D entries are a bit compressed, but that site is not for code golfing. It's just preferred to not write long programs, for several reasonable reasons. code: http://arsdnet.net/dcode/rpc-example.d library:

Re: A little of coordination for Rosettacode

2013-06-16 Thread Adam D. Ruppe
I made a network server/client that needs no library except Phobos. Came in a little under 500 lines but is quite generic: http://arsdnet.net/dcode/server.d The top of the file shows the usage program, then comes the code that could go in a library. Basically you define an interface with a

Re: A little of coordination for Rosettacode

2013-06-16 Thread bearophile
Adam D. Ruppe: I made a network server/client that needs no library except Phobos. Came in a little under 500 lines but is quite generic: Normal Rosettacode entries are under 40-100 lines. Many entries are about 10-20 lines long. There are are few entries (in C or Ada) that reach 500

Re: A little of coordination for Rosettacode

2013-06-16 Thread Adam D. Ruppe
On Sunday, 16 June 2013 at 23:06:40 UTC, bearophile wrote: Normal Rosettacode entries are under 40-100 lines. Many entries are about 10-20 lines long. I think that biases it toward giant standard libraries. I've joked before that we could just say: import rosettacode; mixin Distributed!();

Re: A little of coordination for Rosettacode

2013-06-14 Thread bearophile
There is also one D entry in need to be fixed (with Phobos): http://rosettacode.org/wiki/Distributed_programming#D Bye, bearophile

Re: A little of coordination for Rosettacode

2013-06-14 Thread Adam D. Ruppe
On Friday, 14 June 2013 at 22:17:16 UTC, bearophile wrote: http://rosettacode.org/wiki/Distributed_programming#D It kinda sounds like the description calls for something like what web.d does: server: import arsd.web; class Foo : ApiProvider { export string hello(string name) { return

Re: A little of coordination for Rosettacode

2013-06-14 Thread bearophile
Adam D. Ruppe: This actual example here uses several thousand lines of library code but if you think it would fit the description, I'm sure I can do a basic demo in far fewer lines using nothing but phobos. I think Rosettacode accepts code that uses libraries that are free. Take a look at

Re: A little of coordination for Rosettacode

2013-06-14 Thread Adam D. Ruppe
On Friday, 14 June 2013 at 22:44:40 UTC, bearophile wrote: So if you think this task can be implemented quickly using web.d, then use it :-) I just think it is really cool that D can do that kind of thing, so a brief implementation might be good to show people how it is done. I'll see

Re: A little of coordination for Rosettacode

2013-06-14 Thread bearophile
Adam D. Ruppe: I'll see about slapping something together over the weekend and posting it here. If you use a library, please also give the link to the library, so I can create a nearly empty page on Rosettacode about it. It's kind of needed. Bye, bearophile

Re: A little of coordination for Rosettacode

2013-06-13 Thread bearophile
Some of the last ones that are undone still: http://rosettacode.org/wiki/Birthday_problem http://rosettacode.org/wiki/Suffix_tree http://rosettacode.org/wiki/Deming%27s_Funnel Bye, bearophile

Re: A little of coordination for Rosettacode

2013-04-18 Thread bearophile
Maybe there is a way to translate this Haskell version to D with bigints: http://rosettacode.org/wiki/Find_largest_left_truncatable_prime_in_a_given_base#Haskell Unrelated: now I have a kind of efficient longest common subsequence algorithm with O(n) memory usage. Maybe there is some

Re: A little of coordination for Rosettacode

2013-04-06 Thread bearophile
Jos van Uden: http://rosettacode.org/wiki/Set_puzzle#Alternative_Version Ledrug tagged it. The output says: striped open open. That shouldn't happen. I don't know what's wrong, and why, so I've killed that alternative version... Bye, bearophile

Re: A little of coordination for Rosettacode

2013-04-05 Thread bearophile
I you want to take a look, I've seen that my translation of the Python entry was tagged as wrong: http://rosettacode.org/wiki/Set_puzzle#Alternative_Version Bye, bearophile

Re: A little of coordination for Rosettacode

2013-04-05 Thread Jos van Uden
On 5-4-2013 14:23, bearophile wrote: I you want to take a look, I've seen that my translation of the Python entry was tagged as wrong: http://rosettacode.org/wiki/Set_puzzle#Alternative_Version Ledrug tagged it. The output says: striped open open. That shouldn't happen.

Re: A little of coordination for Rosettacode

2013-04-05 Thread bearophile
Jos van Uden: That shouldn't happen. Do you know why that shouldn't happen? :-) Bye, bearophile

Re: A little of coordination for Rosettacode

2013-03-27 Thread Jos van Uden
On 27-3-2013 0:20, bearophile wrote: This task has just a Tango entry: http://rosettacode.org/wiki/Concurrent_computing So I am writing a Phobos version. This seems to work as requested: import std.stdio, std.random, std.parallelism, core.thread, core.time; void main() { foreach (m;

Re: A little of coordination for Rosettacode

2013-03-27 Thread Jos van Uden
On 27-3-2013 15:17, Jos van Uden wrote: On 27-3-2013 0:20, bearophile wrote: This task has just a Tango entry: http://rosettacode.org/wiki/Concurrent_computing So I am writing a Phobos version. This seems to work as requested: import std.stdio, std.random, std.parallelism, core.thread,

Re: A little of coordination for Rosettacode

2013-03-27 Thread bearophile
Jos van Uden: Output on my system: C:\test Rosetta Enjoy Code C:\test Code Enjoy Rosetta Thank you for your test, I will replace the Rosettacode one with the nicer version. I don't know why the second doesn't work correctly on my system, while the first works. Bye, bearophile

Re: A little of coordination for Rosettacode

2013-03-26 Thread bearophile
This task has just a Tango entry: http://rosettacode.org/wiki/Concurrent_computing So I am writing a Phobos version. This seems to work as requested: import std.stdio, std.random, std.parallelism, core.thread, core.time; void main() { foreach (m; [Enjoy, Rosetta, Code])

Re: A little of coordination for Rosettacode

2013-03-24 Thread bearophile
Some comments about the recently created Vampire number task in Rosettacode: The version I have modified: http://rosettacode.org/mw/index.php?title=Vampire_numberdiff=154069oldid=154068 Fwend has reverted most of my changes: http://rosettacode.org/wiki/Vampire_number#D The

Re: A little of coordination for Rosettacode

2013-03-24 Thread bearophile
- Removal of if (auto factors = ...): coding standards suggest to avoid mixing conditional tests with actions. Keeping code more tidy is safer. Also in D testing array emptiness like that is generally dangerous. The idiomatic and correct way to do it in D is to use empty. Because in general

Re: A little of coordination for Rosettacode

2013-03-24 Thread bearophile
A new version of Vampire number, do you like it? http://codepad.org/DaVxWpoA Bye, bearophile

Re: A little of coordination for Rosettacode

2013-03-24 Thread Jos van Uden
On 24-3-2013 21:02, bearophile wrote: Some comments about the recently created Vampire number task in Rosettacode: The version I have modified: http://rosettacode.org/mw/index.php?title=Vampire_numberdiff=154069oldid=154068 Fwend has reverted most of my changes:

Re: A little of coordination for Rosettacode

2013-03-24 Thread bearophile
Jos van Uden: I think it's convenient, it checks for null or empty, I don't find it confusing at all. I agree it's shorter and it looks handy. But one of its problems is that in D there are arrays with length zero that aren't null: import std.stdio; int[] foo() { auto a = [1];

Re: A little of coordination for Rosettacode

2013-03-24 Thread bearophile
In the vampire code this doesn't happen because you return null (that is represented by two zero words), but in general unlike Python in D the safe and idiomatic way to test for array emptiness is to use std.array.empty. Otherwise you risk having problems. I have just opened a thread in the

Re: A little of coordination for Rosettacode

2013-03-20 Thread ixid
On Tuesday, 19 March 2013 at 18:53:21 UTC, bearophile wrote: Small changes on your version: http://codepad.org/E9KHKvAi It's now on Rosettacode. I have added more changes to make it able to deal with immutable input. Bye, bearophile Another issue to consider as the question I was

Re: A little of coordination for Rosettacode

2013-03-20 Thread bearophile
ixid: The prime factorization of 1 is an empty set, so surely to be correct it should return [] when given 1 and not throw an exception. The Task says that the input can't be 1, so the input 1 needs to be a pre-condition violation: Write a function which returns an array or collection

Re: A little of coordination for Rosettacode

2013-03-19 Thread ixid
I was just looking at the Rosetta code for prime decomposition and it seems bugged to me, wanted to make sure as you seem to be the one coordinating these things: http://rosettacode.org/wiki/Prime_decomposition#D This will potentially return a 1 in the list of primes which is a bug as 1

Re: A little of coordination for Rosettacode

2013-03-19 Thread Andrea Fontana
On Tuesday, 19 March 2013 at 15:55:19 UTC, ixid wrote: I was just looking at the Rosetta code for prime decomposition and it seems bugged to me, wanted to make sure as you seem to be the one coordinating these things: http://rosettacode.org/wiki/Prime_decomposition#D This will potentially

Re: A little of coordination for Rosettacode

2013-03-19 Thread bearophile
ixid: http://rosettacode.org/wiki/Prime_decomposition#D This will potentially return a 1 in the list of primes which is a bug as 1 isn't prime. From Python code, hopefully more correct and much faster: http://codepad.org/N4A7kxE1 Bye, bearophile

Re: A little of coordination for Rosettacode

2013-03-19 Thread ixid
On Tuesday, 19 March 2013 at 16:47:43 UTC, Andrea Fontana wrote: On Tuesday, 19 March 2013 at 15:55:19 UTC, ixid wrote: I was just looking at the Rosetta code for prime decomposition and it seems bugged to me, wanted to make sure as you seem to be the one coordinating these things:

Re: A little of coordination for Rosettacode

2013-03-19 Thread ixid
On Tuesday, 19 March 2013 at 17:18:01 UTC, bearophile wrote: ixid: http://rosettacode.org/wiki/Prime_decomposition#D This will potentially return a 1 in the list of primes which is a bug as 1 isn't prime. From Python code, hopefully more correct and much faster:

Re: A little of coordination for Rosettacode

2013-03-19 Thread bearophile
Small changes on your version: http://codepad.org/E9KHKvAi It's now on Rosettacode. I have added more changes to make it able to deal with immutable input. Bye, bearophile

Re: A little of coordination for Rosettacode

2013-03-05 Thread Jos van Uden
On 5-3-2013 2:05, bearophile wrote: But if you fear that, then I've added private to all global identifiers: http://rosettacode.org/wiki/Simple_database#D I have removed private again, because it's bad to program compromises. This is a complete program, it's not a module, and it's not

Re: A little of coordination for Rosettacode

2013-03-05 Thread Jos van Uden
On 5-3-2013 11:45, Jos van Uden wrote: On 5-3-2013 2:05, bearophile wrote: But if you fear that, then I've added private to all global identifiers: http://rosettacode.org/wiki/Simple_database#D I have removed private again, because it's bad to program compromises. This is a complete program,

Re: A little of coordination for Rosettacode

2013-03-05 Thread bearophile
Jos van Uden: // this shouldn't happen test.d import simdb; If I try to compile something like that my dmd gives me a duplicated main error, or something similar. I really mean: test.d void fun() { auto db = load(); // etc store(db); } simdb.d import test; fun();

Re: A little of coordination for Rosettacode

2013-03-05 Thread Jos van Uden
On Tuesday, 5 March 2013 at 13:12:49 UTC, bearophile wrote: Jos van Uden: // this shouldn't happen test.d import simdb; If I try to compile something like that my dmd gives me a duplicated main error, or something similar. Sorry, that was a wrong example. I really mean: test.d void

Re: A little of coordination for Rosettacode

2013-03-04 Thread bearophile
Now and then this thread becomes very useful for some coordination and discussion. Regarding this Task: http://rosettacode.org/wiki/Take_notes_on_the_command_line#D Fwend has recently modified it with this note: the file only needs to be created before append; filename can be written as one

Re: A little of coordination for Rosettacode

2013-03-04 Thread Jos van Uden
On 4-3-2013 23:04, bearophile wrote: Now and then this thread becomes very useful for some coordination and discussion. Regarding this Task: http://rosettacode.org/wiki/Take_notes_on_the_command_line#D Fwend has recently modified it with this note: the file only needs to be created before

Re: A little of coordination for Rosettacode

2013-03-04 Thread Jos van Uden
On 5-3-2013 0:57, Jos van Uden wrote: On 4-3-2013 23:04, bearophile wrote: Now and then this thread becomes very useful for some coordination and discussion. Regarding this Task: http://rosettacode.org/wiki/Take_notes_on_the_command_line#D Fwend has recently modified it with this note: the

Re: A little of coordination for Rosettacode

2013-03-04 Thread bearophile
Jos van Uden: It depends on how you interpret it. The task describes two actions: display and append. The question is: does the last sentence refer to the append action or to both display and append. I choose to think it refers to the append action because that makes more sense. OK. - - -

Re: A little of coordination for Rosettacode

2013-03-04 Thread bearophile
Jos van Uden: Another consideration, I just remembered, was that it avoided creating global variables. Right, that's important, but every rule should be followed with a grain of salt. First of all in this program there are no global variables, just a global immutable, filename. Global

Re: A little of coordination for Rosettacode

2013-03-04 Thread Jos van Uden
On 5-3-2013 1:20, bearophile wrote: Jos van Uden: It depends on how you interpret it. The task describes two actions: display and append. The question is: does the last sentence refer to the append action or to both display and append. I choose to think it refers to the append action because

Re: A little of coordination for Rosettacode

2013-03-04 Thread bearophile
Jos van Uden: but it doesn't feel right to have these functions publicly accessible. It's a matter of good coding practice. If I import a module these functions are exposed. I think you can't import this module, because it has a main(). But if you fear that, then I've added private to all

Re: A little of coordination for Rosettacode

2013-03-04 Thread bearophile
But if you fear that, then I've added private to all global identifiers: http://rosettacode.org/wiki/Simple_database#D I have removed private again, because it's bad to program compromises. This is a complete program, it's not a module, and it's not imported. No need for private things.

Re: A little of coordination for Rosettacode

2013-02-27 Thread FG
On 2013-02-26 15:10, bearophile wrote: This third version is much simpler and it seems good enough for Rosettacode: http://codepad.org/YJjb1t91 Nice. Myself I'd add bits.reverse; after the N.iota.map..., because I'm more used to a truth table where the left-most operands iterate the slowest.

Re: A little of coordination for Rosettacode

2013-02-27 Thread FG
On 2013-02-27 12:47, FG wrote: On 2013-02-26 15:10, bearophile wrote: This third version is much simpler and it seems good enough for Rosettacode: http://codepad.org/YJjb1t91 Nice. Myself I'd add bits.reverse; after the N.iota.map..., because I'm more used to a truth table where the

Re: A little of coordination for Rosettacode

2013-02-27 Thread bearophile
A possible idea is to translate this last Python version to D: http://rosettacode.org/wiki/Hamming_numbers#Cyclic_generator_method_.232. - - - - - - - - - - - - Another idea is to add a D version of Merge Sort that works with just a Input Range (like a single linked list, as a SList):

Re: A little of coordination for Rosettacode

2013-02-26 Thread bearophile
Jos van Uden: But I couldn't figure out how to expand the boolean array to an argument list. I wrote a version, it's more statically type safe, but the code is quite hairy, and the foreach(i) generates too many templates if the predicate has many bool arguments:

  1   2   >