double OOPS!

my revised version was as fast as yours.  It's the same method as yours, 
really.

(when i said my second version wasn't better than my first, it's because 
i somehow managed to time my first version twice instead of first then 
second. (D'oh!))

mcCormickConcatInt =. ([: ". [: ; 'x',~ ' '-.~ ":)
(6!:2) 'mcCormickConcatInt 500 $ 1234567890'
     NB. 0.00043788251564

mijjConcatIntV1  =. ,&'x'@,&.":
(6!:2) 'mijjConcatIntV1/ 500 $ 1234567890'
     NB. 0.123353910604

mijjConcatIntV2  =. (,&'x')@(-.&' ')&.":
(6!:2) 'mijjConcatIntV2 500 $ 1234567890'
     NB. 0.000435476567752

so .. vast improvement on time if not converting back and forth.  That 
searching for ' ' doesn't slow it down much does it.


On 2011-07-19 02:03, Devon McCormick wrote:
> Is this any better?
>
> 6!:2 '([: ". [: ; ''x'',~ '' ''-.~ ":)500$1234567890'
>
> On Mon, Jul 18, 2011 at 7:39 PM, mijj<[email protected]>  wrote:
>
>> except .. OOPS! ..
>>
>> my second version is no faster than my first version.
>> all that searching for ' ' i guess.
>>
>> i'm stalled tho.
>>
>> [":("0)] converts the numbers to strings
>>
>> but then there's the need to concat the strings - bearing in mind the
>> strings may be different lengths.
>>
>> On 2011-07-19 00:05, mijj wrote:
>>> oh.. i see ..
>>> you had 'x' dotted along the string version of the number rather than
>>> just at the end.
>>>
>>> my L/R number pair version
>>> [(convert to string) : (concat string): (append 'x') : (convert back to
>>> integer)]
>>> .. lots of converting back and forth for a sequence of numbers.
>>>
>>> so yeh .. faster to :
>>> [(convert all the sequence on the right to a single string including
>> spaces)
>>> (remove the spaces)
>>> (append with 'x')
>>> (convert back to number)
>>> ]
>>>
>>> i.e.
>>> concatNumbers =. (,&'x')@(-.&' ')&.":
>>> concatNumbers 5 $ 1234567890
>>> NB. 12345678901234567890123456789012345678901234567890
>>>
>>>    >: concatNumbers 5 $ 1234567890
>>> NB. 12345678901234567890123456789012345678901234567891
>>>
>>>
>>> first i tried to :
>>> [(convert all the numbers in the sequence on the right to individual
>>> strings)
>>> (concat the strings)
>>> (append with 'x')
>>> (convert back to number)
>>> ]
>>> .. but it got too fiddly.  Easier just to remove the ' ' i thought.
>>>
>>>
>>>
>>> On 2011-07-18 23:21, Brian Schott wrote:
>>>> Yes, nicely done.
>>>>
>>>>> concatIntegers  =. ,&'x'@,&.":
>>>>> concatIntegers/ (5 $ 1234567890)
>>>>
>>>> In continuing to pflog away, I noticed that a slight change of your
>>>> verb works much faster, but doesn't finish well.
>>>>
>>>>       6!:2 ' concatIntegers/ (500 $ 1234567890)'   NB. remember this time
>>>> 1.2667
>>>>       6!:2 ' concatIntegers M./ (500 $ 1234567890)'  NB. no improvement
>>>> 1.23531
>>>>       6!:2 ' concatIntegers /M. (500 $ 1234567890)' NB. no improvement
>>>> 1.29468
>>>>       concatIntegers0  =. ,&'x'@,&":
>>>>       6!:2 ' concatIntegers0/ (500 $ 1234567890)' NB. big improvement
>>>> 0.040116
>>>>       6!:2 ' concatIntegers0/ (5 $ 1234567890)'
>>>> 0.000163078
>>>>       ". concatIntegers0/ (5 $ 1234567890) NB. but cannot return to
>> numbers?
>>>> |ill-formed number
>>>> |       ".concatIntegers0/(5$1234567890)
>>>>       $concatIntegers0/ (5 $ 1234567890) NB. this is why, but can it be
>> fixed?
>>>> 54
>>>>
>>>> On Mon, Jul 18, 2011 at 5:50 PM, mijj<[email protected]>    wrote:
>>>>> (Department of Flogging a Dead Horse)
>>>>>
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to