Talk:Order disjoint list items: Difference between revisions

no edit summary
(→‎Perl 6 entry: perl output)
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 25:
 
There seems to be something wrong with the Perl output, probably a copy and paste error. [[User:Fwend|Fwend]] ([[User talk:Fwend|talk]]) 11:22, 4 June 2014 (UTC)
 
== Task clarification: correct behaviour with duplicates in M and/or N? ==
 
Hi, the Ruby and Scala implementations have been annotated as wrong by [[User:Bart|Bart]] but I currently believe my Scala implementation is correct according to my own interpretation of the task statement, but it’s not entirely clear. Here’s a comparison of Scala with Python and Ruby. I’ve bolded one significant difference. Note, the Python and Ruby versions fail to complete these tests:
 
'''Scala output:'''
Data M: cat cat mat Order N: mat cat -> Result M': mat cat mat
Data M: cat cat mat Order N: '''cat mat''' -> Result M': '''cat mat''' mat
Data M: cat mat Order N: mat mat -> Result M': cat mat
Data M: cat mat Order N: cat mat -> Result M': cat mat
Data M: cat mat Order N: cat mat cat -> Result M': cat mat
Data M: cat mat Order N: mat cat cat -> Result M': mat cat
Data M: cat mat Order N: cat cat mat -> Result M': cat cat
 
'''Python output:'''
Data M: 'cat cat mat' Order N: 'mat cat' -> M' 'mat cat cat'
Data M: 'cat cat mat' Order N: ''''cat mat'''' -> M' ''''cat cat''' mat'
Data M: 'cat mat' Order N: 'mat cat' -> M' 'mat cat'
Data M: 'cat mat' Order N: 'cat mat' -> M' 'cat mat'
Data M: 'cat mat' Order N: 'cat mat cat' Traceback (most recent call last):
File "<stdin>", line 42, in <module>
File "<stdin>", line 11, in order_disjoint_list_items
ValueError: 'cat' is not in list
 
'''Ruby output:'''
Data M: cat cat mat Order N: mat cat -> M' mat cat mat
Data M: cat cat mat Order N: '''cat mat''' -> M' '''cat mat''' mat
-:21:in `[]=': no implicit conversion from nil to integer (TypeError)
from -:21
from -:21:in `reverse_each'
from -:21
from -:23:in `each_slice'
from -:17:in `each'
from -:17:in `each_slice'
from -:17
 
If the Scala implementation is incorrect, can the task please be clarified to avoid this misinterpretation. Alternatively, if all the other impementations are wrong, can the task please be clarified to avoid this misinterpretation :) --[[User:Jnd|Jnd]] ([[User talk:Jnd|talk]]) 10:20, 13 October 2014 (UTC)
 
:Hi Jnd. We have:
::''"Given M as a list of items and another list N of items chosen from M, create M' as a list with the first occurrences of items from N sorted to be in one of the set of indices of their original occurrence in M but in the order given by their order in N."''
 
:For:
:: <code>Data M: cat cat mat Order N: cat mat</code>
:The second cat in M is never indexed by an item in N. <br>
:There is only one cat in N which matches the first cat in M. mat matches the last item in M so only the first and last items in M ''could'' be rearranged by their order in N. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 11:08, 13 October 2014 (UTC)
 
::Thanks Paddy3118, I still can’t get my head around the language, but you’re saying that items in N are taken from M without replacement, then the corresponding positions in M' are taken by successive items from N? --[[User:Jnd|Jnd]] ([[User talk:Jnd|talk]]) 11:45, 13 October 2014 (UTC)
 
== Mathematica has fault ==
 
Mathematica has fault in A B C A B D A B E order by E A D A at the last letter, should be A and is E. Maybe is the copy of results, I didn't execute the code.
404

edits