Talk:Kaprekar numbers: Difference between revisions

m
→‎Just for fun: added a new talk section.
(Undo revision 146030 by Nigel Galloway (talk) restore the discussion)
m (→‎Just for fun: added a new talk section.)
 
(3 intermediate revisions by 2 users not shown)
Line 142:
For fun I tried reversing the digits in the squared number (e.g. using "5203" as the "squared number" for 55 instead of "3025") to see if there would be any pattern in the new results. There were some overlaps for numbers that were all repeating digits. I didn't see anything notable. I got 17 rakerpak (kaprekar backwards....get it?) each for base 10 and 17. The code isn't notable either (just add a bit to one line to reverse the string representation of the squared number). I thought it would be kinda neat to think about. --[[User:Mwn3d|Mwn3d]] 15:16, 8 August 2011 (UTC)
 
 
----
== ooRexx ==
 
I tried this for ooRexx
Had to change # to n
Line 148 ⟶ 150:
It works with Numeric Digits 14
--[[User:Walterpachl|Walterpachl]] 14:53, 29 June 2012 (UTC)
 
 
== Common Lisp Implementation ==
 
Let me start by saying that I feel the criteria that should be used to modify existing code are the following:
*Correctness
*Fulfilling additional tasks / generality
*Improved readability
*Use of a programming languages idioms - For example, in CL the use of multiple return values is preferred to say setting multiple global variables.
*Improved performance
*(Note: There may be some special situations missing from this list)
 
Using these criteria, I modified the original CL implementation mainly because I thought that I could improve the readability by using more Lisp language features like multiple return values. In short, I felt like I was reading a C program written in Lisp: The original code isn't 'Lispy'. Later, I made some changes to the basic algorithm that substantially improved the performance (and even later came across the CO9 technique which again substantially improved performance). Because the original version supports additional number bases, I decided to add a separate fast version and retain the older, more general, version. Recently, [[Nigel Galloway]] added support for all number bases to the 'fast implementation'. Based on the criteria above, I would normally find this to be an improvement, however, the code again resembles a C implementation written in Lisp (especially with the global bindings of BASE and BASE-1) and the performance has also decreased substantially. My version is able to finish the first 1 million Kaprekar numbers in ~9.1 seconds; The new version finishes in ~124 seconds. Memory usage and garbage collection also increased by an order of magnitude.
 
Because the new version lacks additional generality beyond the 'slow version', decreases readability and the use of Lisp idioms, and is substantially slower than the previous version, I've decided to revert the changes made by Nigel. I added this talk section to explain my rationale for making the revision. --[[User:Lhignight|Larry Hignight]] 23:40, 18 September 2012 (UTC)
: Hi Lhignight, its good to see your criteria - I hope they are in decreasing order of importance for the general task, as optimising for speed can detract from the other concerns if done to excess - especially if a task can be 'adequately' fulfilled without it. Although you could add another implementation that was faster and leave a more idiomatic example alone. --[[User:Paddy3118|Paddy3118]] 16:08, 19 September 2012 (UTC)
:: Fleshing this out a bit more, in terms of the order of importance, I consider correctness to be the most important criteria, performance the least (unless specifically mentioned in the task), and the remaining criteria are about equal in my opinion. In most programming languages, improved readability and use of language idioms are often highly correlated (at least among experienced users of the language). Performance is a nice bonus item, but if it detracts from any of the other criteria, it should be added as a separate task assuming that it is correct and significantly faster: 5% faster, skip it; 5x faster, add it. --[[User:Lhignight|Larry Hignight]] 23:38, 21 September 2012 (UTC)
 
Hi Larry, what implementation of common lisp are you using? I only replaced a function number of digits, which calculated the number of digits by dividing by 10 until less than 10 with floor (log N / log Base) which is a reasonable way to determine the number of digits in a number. This should be faster unless your implementation has no reasonable log function. Note that BASE and BASE-1 are not variables they are constants. I didn't change the logic. A mute point now as ledrug has done tha task properly.--[[User:Nigel Galloway|Nigel Galloway]] 18:44, 19 September 2012 (UTC)
: Hi Nigel, I did the initial testing using CLISP. I've since tested both versions using LispWorks, which improved your times substantially, but it is still noticeably slower. I'll separate out your other points so that you can respond to each comment directly. --[[User:Lhignight|Larry Hignight]] 22:42, 23 September 2012 (UTC)
 
"I didn't change the logic."<br>Perhaps you didn't intend to change the logic, but your version fails to identify 9,999,999 and 99,999,999 as Kaprekar numbers whereas mine correctly identifies them, so yes, you did change the logic. --[[User:Lhignight|Larry Hignight]] 22:42, 23 September 2012 (UTC)
 
"Note that BASE and BASE-1 are not variables they are constants."<br>While I applaud the additional mathematical insight that you provided, I'm concerned that you don't have very much experience as a Lisp developer and should probably refrain from modifying existing Lisp solutions. For example, the CLHS explicitly states that [http://www.lispworks.com/documentation/HyperSpec/Body/s_setq.htm setq] is used with variables "other than a constant variable." In addition to BASE and BASE-1 not being constants, which isn't what you didn't want in the first place, there are a number of other issues:
*In CL, the standard method for defining a constant is the [http://www.lispworks.com/documentation/HyperSpec/Body/m_defcon.htm defconstant] form. It is also the convention in CL to name constants with leading and trailing + characters (eg +base+).
*The unnecessary use of dynamically scoped variables is discouraged. The preferred method for incorporating base would have been to define it as an optional function parameter with a default value of 10.
*The manner in which you replaced the num-digits macro resulted in code that was less readable. In my version, it was very clear when the number of digits were being calculated because I used an abstraction to separate this calculation from the function. You eliminated a useful abstraction.
*For some reason, you replaced the let* form with the lh and rh values with a multiple-value-bind form. I really have no idea why you would do this.
*I'm not sure why you feel that two calls to log followed by floor() and adding 1 would be faster than a loop that runs in theta(log n) time. --[[User:Lhignight|Larry Hignight]] 22:42, 23 September 2012 (UTC)
 
"A mute point now as ledrug has done tha task properly."<br>Yeah, it's kind of a shame that someone broke it though. --[[User:Lhignight|Larry Hignight]] 22:42, 23 September 2012 (UTC)
 
A lot of hot air for somthing that doesn't exist! I did not break the origional solution, I made it solve the task. Obviously in a way that doesn't suit you. In place of personal abuse you might have changed it to suit you and solve the task. Returning it to a version which doesn't solve the task was not helpful. I was going to restore my version and let you change it, but I'll leave it to you to restore and correct if you think it adds anything. I have a much better idea.--[[User:Nigel Galloway|Nigel Galloway]] 10:40, 26 September 2012 (UTC)
:YOUR version is not CORRECT. Anyone can view the history, try the examples above, and see this is true. I left untouched a slower version that solved the 'Extra extra credit' task, which you seem to be obsessed with for some reason. Why you would expect anyone to fix an incorrect, slower, less readable, and less lispy version of your software, when better versions already existed, is way beyond me. --[[User:Lhignight|Larry Hignight]] 01:17, 30 September 2012 (UTC)
Now with +SCARY CAPITALS+! I dont't expect anyone to do anything, it was merely a suggestion that you 'put up or shut up'. I modified your solution so that it worked, with sample output provided. If it didn't work for large numbers (ouside the scope of the task) it is probably because your log algorithms are inaccurate. You changed it back to your solution, which doesn't solve the task. Your situation is that ledrug didn't like your solution and has replaced it with his. If you have nothing to put up on the task page then all this is just hot air. None of your comments and insults have indicated that which you wish me to do about your situation. As I said I have a better idea, which I have placed on the task page.--[[User:Nigel Galloway|Nigel Galloway]] 11:38, 1 October 2012 (UTC)
:How on earth is something that doesn't work CORRECTLY a better idea! And for the record, Ledrug replaced YOUR version, not mine. --[[User:Lhignight|Larry Hignight]] 08:24, 4 October 2012 (UTC)
 
Well, joining the fray. First, the message left on my user talk page by one genius:
:Please leave [http://rosettacode.org/wiki/Kaprekar_numbers#In_the_style_of_the_C.2B.2B_generator this code] alone until you can demonstrate an understanding of this problem. Your second attempt at this is an improvement over your first naive attempt, but still not as interesting as [http://rosettacode.org/wiki/Kaprekar_numbers#In_the_style_of_the_C.2B.2B_generator this]. Maybe I shall seperate the [http://rosettacode.org/wiki/Casting_out_nines Casting_out_nines] from the Kaprecar part: <lang clisp>(let ((kk (* N N))) (do ((B Base (* B Base))) ()(let (( nr (/ (* N (- B N)) (- B 1)))) (if (< 0 nr) (let ((q (floor (- N nr)))) (if (= kk (+ nr (* q B)))</lang> (unsigned, left by [[User:Nigel Galloway]])
I'll make a few comments, but won't discuss it any more after that, since that would be obviously futile.
# I don't know what kind of antique lisp machine you have installed in your basement, but your code does not compile on either SBCL or Clisp. Maybe geniuses shan't be bothered by such trifles.
# Your code, once made compile with SBCL (change that <code>do (...) ()</code> to <code>do (...) (nil)</code>, does exactly the samething mathematically: raise a power of a base repeately, until either it splits the square of n with the right sum, or it's too large. Except you are doing it in a convoluted way, using non-integer methods on integers, and ends up with something literally 100 times slower then my edit you reverted (on SBCL that is, I don't know about your antique lisp machine).
# You had one good idea of checking congruence, and a whole lot of terrible ones: being thoughtless in dealing with datatypes (<code>pow</code> and <code>log</code> on integers in C++, <code>/</code> and <code>floor</code> in Lisp); being sloppy in performance tuning (your "v.fast" C++ code isn't all that fast); being vengeful (<code>paddy_cnt</code>?); being narcissistic (own name as variable?); being inconsiderate to code readers (what kind of person posts unindented Lisp?); and generally being an all-around dick.
::Thank you for admiring me as the most beautiful youth in the world! In this section I have detected ehoes of Echo 'twix you and your Acolyte, but as in the myth I must reject your sexual advances. I think it is going to take more than me seeing my own reflection to appreciate the inner goodness of either of you two clowns.--[[User:Nigel Galloway|Nigel Galloway]] 13:32, 13 October 2012 (UTC)
# Your sarcasm in the lisp code was neither subtle nor funny. You give British humor a bad name.
 
You are probably not stupid, but it's safe to say you are not the smartest person on RC, by a long shot. And smart people around here tend to have good manners, unlike you or I. Stop treating yourself like you are the one true genius, and try to do something that's helpful to people instead of showing off, OK? (my guess: probably not. Oh well.) --[[User:Ledrug|Ledrug]] 00:10, 4 October 2012 (UTC)
:Well said. He is clearly more interested in being a pompous dick then contributing quality code to RC. --[[User:Lhignight|Larry Hignight]] 08:24, 4 October 2012 (UTC)
:There are no stupid people only differently logical. I look forward to seeing this list of rosettacode contributers arranged by smartness that they propose. I assume they exclude themselves from it as judges, and including them would be laughable. The good news for ledrug is that on my list of differently logical contributers, from which I exclude myself as judge, he has been replaced by his new acolyte as first clown.--[[User:Nigel Galloway|Nigel Galloway]] 11:08, 11 October 2012 (UTC)
 
Again ledrug why so angry? I didn't revert your edit, it is a good solution, I left it there and reinstated my solution which you deleted, as, indeed, it was you who deleted Larry's solution. There are three approaches to this problem which I have identified:
:1) a naive approach which loops over all numbers testing each fully for Kaprekarness (your first solution);
:2) a more sophiscated method which still loops over all numbers but implements a filter based on casting out nines which quickly eliminates seven nineths of the numbers (your second solution, thank you for praising my idea);
:3) realizing the nature of the uneliminated numbers it is possible to identify the residual sets to which possible Kaprekar numbers belong and generate them (which my solution does).
 
I therefore asked you not to delete it, and I said please! I asked you to understand the difference before you changed it, which you may. Agian I would say politely, I said please. Again I thank you for your praise for that which you judge to be my good idea, though of course without accepting your magesterium regarding the quality of any of my ideas.
 
I use Franz Allegro 9, do you want me to pass your comments 'kind of antique lisp machine you have installed in your basement' on to them? Also the version I use is case sensitive, so your use of t and T to disguish when you want t to mean true and T to mean boolean causes my rather advanced lip machine to identify T as an unbound variable, but I just quietly change it without impuning either you, SBCL, or CLisp.
 
Finally I have no reason to be vengeful to Paddy, I don't even feel vengeful towards you! He asked that the impementation include a count of the Kaprekars as requested in the task description, and I obliged. I named the count after him as my terrible vengence, I don't see it.--[[User:Nigel Galloway|Nigel Galloway]] 12:12, 4 October 2012 (UTC)
 
===Conflict Resolution?===
Hi guys, I and probably others have been lurking on this issue that doesn't seem to be getting closer to a solution. I am not a Lisp expert, but would like to see some resolution.
:How about a limited debate? Nigel, Ledrug and Larry should continue the debate for no longer than, say next Monday - others can add their opinions too but the idea being to leave behind reasoned areguments why their view should prevail. Come Tuesday others should read the reasoned arguments and make up their own minds with the page updated to fit the best reasoned point. Or Mike Mol could become a benevolent dictator on Tuesday and just state *the* resolution, to be followed by all.
 
- Or not. If someone has another idea ...? --[[User:Paddy3118|Paddy3118]] 13:26, 4 October 2012 (UTC)
: Don't worry about my side, I've said what I wanted to say, and am not getting back into it. Though I'm pessimistic about ''everyone'' eventually agreeing to a reasonable resolution: I wouldn't have flat out called someone a self-important dick if past experience showed that he could be reasoned with or that he did have a bit of sincerity when exhibiting his knowledge in spelling the word "please". I'd like to be wrong on this, but I won't hold my breath. --[[User:Ledrug|Ledrug]] 05:59, 5 October 2012 (UTC)
 
:I wrote a list of reasons concerning when I think it is appropriate to change existing code and why I changed Nigel's version (his 7/9/2012 submission) to which he responded with "A lot of hot air for somthing that doesn't exist!" ignoring ALL of my points and implying that I should have fixed his version: "I was going to restore my version and let you change it". I feel that the criteria that I previously listed are still valid, and despite what Nigel might claim, there are major issues with his version (in terms of Lisp constructs, idioms and formatting) which is why I removed his version, and not because I was being vengeful, as he stated below. His submission is badly written and should be removed. It is that simple. If Nigel would like to change the version written by Ledrug, I feel that he should write a list of valid reasons which can be debated. If the reasons are sound and agreeable, then he be allowed to modify Ledrug's version with one caveat: All of Nigel's Common Lisp submissions have been extremely poorly written and indicative of someone who does not care to either learn or write proper Lisp code, so the submission should be vetted here, on the talk page, before he is allowed to post it on the task page. --[[User:Lhignight|Larry Hignight]] 03:49, 8 October 2012 (UTC)
::Ledrug replaced your version at 04:55, 19 September 2012, I responded to your explanation at 18:44, 19 September 2012 (UTC). I accepted that you had undone the changes and explained why I had made them. No mention of 'hot air', the response finished with A mute point now as ledrug has done tha task properly. You made a long response on 23 September. 26th September I responded with "A lot of hot air for somthing that doesn't exist!". If you thought, and I agree with you, that "Ledrug (had already) submitted a single version that was faster than mine (Larry), well-written, and worked for all number bases" what is there to discuss. You have agreed that he replaced your version to "reduce code; simplify; speed up; conform to task and extra". Does this not imply that your code needed improving? Only if you resurect and improve your (rubbish?) version is the subject interesting. I have responded to the issue you have raised regarding my current submission below.--[[User:Nigel Galloway|Nigel Galloway]] 12:44, 9 October 2012 (UTC)
:::Nigel, the code that Ledrug contributed was beneficial because it worked in additional number bases and was faster than my submission. The code that you submitted looked like something a drunk C programmer would have written while doing a first experiment with CL. Not only was it horribly written CL, it clearly did not work correctly: Any number consisting of only nines is a Kaprekar number (in case you didn't get the memo). Please don't confuse the rubbish that you submitted with something that completed the task because it clearly did not solve it. --[[User:Lhignight|Larry Hignight]] 04:28, 16 October 2012 (UTC)
 
I can identify three issues, none requiring any particular Lisp knowledge to resolve:
 
==== Issue the first ====
Sorry Paddy, you are probably going to have to pass the first to Michael. It is really a matter of editorial policy under what circumstances it is acceptable on rosetta code to call someone a "pompous dick" (if it is acceptable, how far may I go in responding?). Either way I can take it, boys will be boys. I don't know why ledrug chose to vomit over rosetta code, he seems to think his bile is reason, and to be suprised that it doesn't have the effect on me he thinks it should.
 
==== Issue the second ====
As Larry says "Anyone can view the history". Let's do so.
:(cur | prev) 23:12, 19 September 2012? Ledrug (Talk | contribs)? m (84,428 bytes) (?{{header|Common Lisp}}: improve silly logic) (undo)
:(cur | prev) 04:55, 19 September 2012? Ledrug (Talk | contribs)? (84,438 bytes) (?{{header|Common Lisp}}: reduce code; simplify; speed up; conform to task and extra) (undo)
:(cur | prev) 00:12, 19 September 2012? Lhignight (Talk | contribs)? (88,507 bytes) (?{{header|Common Lisp}}: Updated the description of the 'fast' implementation.) (undo)
:(cur | prev) 23:54, 18 September 2012? Lhignight (Talk | contribs)? (88,429 bytes) (Undo revision 140330 by Nigel Galloway (talk)) (undo)
:(cur | prev) 23:52, 18 September 2012? Lhignight (Talk | contribs)? (90,240 bytes) (Undo revision 140337 by Paddy3118 (talk)) (undo)
:(cur | prev) 23:50, 18 September 2012? Lhignight (Talk | contribs)? (90,151 bytes) (Undo revision 140331 by Nigel Galloway (talk)) (undo)
:(cur | prev) 23:47, 18 September 2012? Lhignight (Talk | contribs)? (90,293 bytes) (Undo revision 140336 by Nigel Galloway (talk) See the CL section of the talk page for further discussion) (undo)
:(cur | prev) 11:38, 9 July 2012? Nigel Galloway (Talk | contribs)? (79,959 bytes) (?{{header|Common Lisp}}) (undo)
 
I made a change to Larry's Common Lisp implemantation to make it work on 9 July 2012.
:Nigel, my version did work. Your changes did NOT work and I wrote a number of bullets points addressing the issues with your version, which you chose to ignore, and instead responded to these valid concerns in an arrogant and pompous manner. You had the opportunity to respond to my criticism of your naming conventions, unnecessary use of globals (and later constants), use of setq, improper use of multiple-value-bind, poor readability/use of abrstaction, and other issues, including the FACT that your code FAILED to identify 9,999,999 as a Karprekar number. Instead, YOU chose to dismiss all of these valid concerns by stating that I was full of "hot air" and further suggest that the proper thing would have been for me to have fixed your version. --[[User:Lhignight|Larry Hignight]] 03:49, 8 October 2012 (UTC)
 
This stood until 18 September 2012, when Larry unidid the changes returning the implementation to a less than working solution.
:Again, I undid your changes because the version that you posted was INCORRECT and BADLY WRITTEN Common Lisp. Your reference to my version as being 'less than a working solution' is another example of the bullshit comments that you continuously make in a vain attempt to deflect valid criticism of your submissions. --[[User:Lhignight|Larry Hignight]] 03:49, 8 October 2012 (UTC)
 
Ledrug completely replaced Larry's solution with a working example on 19 September 2012. For some reason Larry thinks I broke his solution and says "And for the record, Ledrug replaced YOUR version, not mine.". I think Larry is simply wrong in fact.
:Nigel, YOU originally replaced my version starting this whole mess. Here is the precise order of events:
* June 21 -- I (Larry) added a 2nd fast version that was quite a bit faster, easier to read, used additional Lisp forms AND only worked in base-10 (which is why I left the original version).
** Both vesions were correct.
* July 3 -- I (Larry) added the 'modular arithmetic filter' and additional output to the fast version that I had submitted.
* July 9 -- You (Nigel) made three changes updates to my version; I was busy at the time had didn't have time to review your changes.
* July 9 -- Paddy removed our names from the comment log.
* Sept 18 -- After reviewing your version, which I found to be both incorrect and badly written, I undid you changes and posted why on the talk page.
** You responded with the "hot air" comment and stated I should have fixed your code.
::Again wrong in fact. Ledrug replaced your version at 04:55, 19 September 2012, I responded to your explanation at 18:44, 19 September 2012 (UTC). I accepted that you had undone the changes and explained why I had made them. No mention of 'hot air', the response finished with A mute point now as ledrug has done tha task properly. You made a long response on 23 September. 26th September I responded with "A lot of hot air for somthing that doesn't exist!". If you thought, and I agree with you, that "Ledrug (had already) submitted a single version that was faster than mine (Larry), well-written, and worked for all number bases" what is there to discuss. Only if you resurect and improve your version is the subject interesting--[[User:Nigel Galloway|Nigel Galloway]] 13:05, 8 October 2012 (UTC)
*later, Ledrug submitted a single version, which he later updated with the mod filter, that was faster than mine, well-written, and worked for all number bases.
** I believe Ledrug's current version is the best CL implementation of the task and should be the only version UNLESS someone using the code change criteria has valid reasons for changing it. --[[User:Lhignight|Larry Hignight]] 03:49, 8 October 2012 (UTC)
::Why only one version? There are four ways to implement this task.--[[User:Nigel Galloway|Nigel Galloway]] 13:05, 8 October 2012 (UTC)
:::Your current version does not work. I have attempted to compile it on three Lisp implementations to date. Submit something that is well written CL code that compiles on standard CL implementations and then we can discuss whether or not an additional version is warranted. --[[User:Lhignight|Larry Hignight]] 04:28, 16 October 2012 (UTC)
 
The problem is that ledrug replaced Larrys solution to, in ledrug's description "reduce code; simplify; speed up; conform to task and extra improve silly logic". This has made Larry angry, I think with the wrong person.
:This is not true at all. First, you are the only person that I have been angry with due to your dismissive and insulting comments. Second, it is clear that Ledrug's 'silly logic' comment was in reference to a loop condition that he had written. --[[User:Lhignight|Larry Hignight]] 03:49, 8 October 2012 (UTC)
 
I would prefer that ledrug did not so overwrite someone elses work, but Larry seemed more interested in pointless abuse of me than improving and justifying his solution. Anyway I had a better idea.
:Unbelievable. I wrote valid criticisms about the CORRECTNESS and READABILITY of the changes that YOU made to my submission. Something that you seem incapable of responding to in a professional manner. --[[User:Lhignight|Larry Hignight]] 03:49, 8 October 2012 (UTC)
::Larry, how old are you? You have accepted that "Ledrug submitted a single version, which he later updated with the mod filter, that was faster than mine, well-written, and worked for all number bases." You have agreed that he replaced your version to "reduce code; simplify; speed up; conform to task and extra". Does this not imply that your code needed improving? I am not interested in your critisism of me, though when it degenerates to "Well said. He is clearly more interested in being a pompous dick then contributing quality code to RC" I don't think it is acceptable.--[[User:Nigel Galloway|Nigel Galloway]] 13:05, 8 October 2012 (UTC)
:::I called you a pompous dick AFTER you started dismissing valid criticisms with smart ass remarks, confusing the issue with lies on this talk page and then writing unwarranted comments on someone's user page. If you don't like being called a dick, then stop acting like a dick. It's pretty simple, really. Regarding your latest lie and attempt at confusing the issue, "You have agreed that he replaced your version to 'reduce code; simplify; speed up; conform to task and extra'," I never said that Ledrug's version reduced my code, simplified my code, or agreed to anything on this page. Ledrug's change comments were (once again) comments about his code. He improved his code. You should consider doing the same. --[[User:Lhignight|Larry Hignight]] 04:28, 16 October 2012 (UTC)
 
==== Issue the third ====
I have identified 3 approaches to this task:
1) a naive approach which loops over all numbers testing each fully for Kaprekarness;
2) a more sophiscated method which still loops over all numbers but implements a filter based on casting out nines which quickly eliminates seven nineths of the numbers;
3) realizing the nature of the uneliminated numbers it is possible to identify the residual sets to which possible Kaprekar numbers belong and generates them.
 
ledrug's solution was of the first ilk, my better idea was to implemented a solution of the third. ledrug responded by upgrading his solution to type 2 and overwrote my solution with his. I recovered my solution and left ledrug's second solution in tact. He says's "then my edit you reverted" (sic), perhaps he didn't check the changes and thought I had deleted his - I had not. I may work further on this solution. I have noticed that the first 2 Kaprekars are in ran and that the test is simpler when it only needs to identify Kaprekars larger than Base. I have asked ledrug to leave this solution in place. I think he will comply even though he thinks saying please is bad manners. Larry didn't leave it, but I just put that down to vengence, the only reason he supplied is that ledrug has taught him to swear. I have supplied two good C++ solutions, but have not deleted the origional rather slow version. Ledrug has now implemented a fourth method, without deleting any one elses. Is that not better?
--[[User:Nigel Galloway|Nigel Galloway]] 13:15, 7 October 2012 (UTC)
 
=== Testing Common Lisp Contributions ===
Just to confirm my suspicions about the quality of Nigel's CL submissions, I decided to test both Ledrug and Nigel's current versions:
* Ledrug's version:
** Compiled on both CLISP and LispWorks without requiring any changes
** Was extremely fast; In fact, it was faster than Nigel's 'vfast' C++ version for n = 1 million (.85s vs 1.20s)
*** The C++ compilation done with MinGW. The CL compilation with LispWorks. I did not set the compiler to optimize in either case.
* Nigel's version:
** Does not compile on CLISP: exit clause in DO must be a list
** Does not compile on LispWorks: NIL does not match (SYSTEM::END-TEST-FORM &REST SYSTEM::RESULT-FORMS)
:::The following is tha ANSI specification fon NIL
<pre>
1.4.1.4.4 NIL
 
nil has a variety of meanings. It is a symbol in the common-lisp package with the name "NIL", it
is boolean (and generalized boolean) false, it is the empty list, and it is the name of the empty
type (a subtype of all types).
 
Within Common Lisp, nil can be notated interchangeably as either NIL or (). By convention, the
choice of notation offers a hint as to which of its many roles it is playing.
 
Notations for NIL
For Evaluation? Notation Typically Implied Role
Yes nil use as a boolean.
Yes 'nil use as a symbol.
Yes '() use as an empty list
No nil use as a symbol or boolean.
No () use as an empty list.
</pre>
:::From which I and my "antique lisp machine ... installed in your (my) basement" conclude that () may be used as an empty list. Apparently your advanced implementations don't, but this is Lisp for you.--[[User:Nigel Galloway|Nigel Galloway]] 12:14, 9 October 2012 (UTC)
::::'() can be used as an empty list on all Common Lisp implementations including SBCL, Clisp and LispWorks. Try again. --[[User:Lhignight|Larry Hignight]] 04:28, 16 October 2012 (UTC)
 
I'm sure that Nigel will respond to these results in his usual manner: "that is hot air", "all of your implementations are flawed; Mine is the only true Common Lisp", "Surely, you must have my version and Ledrug's version mixed up", or even the classic "Why didn't you just fix my code!" Who knows... I'm sure that it will be amusing though. Therefore, I encourage everyone with a working CL implementation to attempt to compile both versions and post your results. --[[User:Lhignight|Larry Hignight]] 07:45, 8 October 2012 (UTC)
::Always happy to exceed expectations. If it is amusing you want, let me put another nail in British humour: Do you know the definition of a Yankee?; A bit like a quickie but he does it himself.--[[User:Nigel Galloway|Nigel Galloway]] 11:12, 10 October 2012 (UTC)
:::Yeah, that wasn't up to your usual standards. --[[User:Lhignight|Larry Hignight]] 04:28, 16 October 2012 (UTC)