Re: ? 1={}, is there really any other interpretation?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Andy Serpa wrote:

> No one ever uses code like this?  It makes things so easy because
> the boolean mask sequence can be made so easily with one operator.

I used to use it all the time until I found out that loops are faster. :/

> Not to mention the ease of doing math on whole sequences (or even matrices)
> at once.  Isn't it nice to be able to type
> 
> s/100 instead of looping through s and dividing each element?

You should run some tests and see what methods are fastest.

Well, actually, I just ran some tests using this code:

include get.e

sequence s, x
atom z, hi, lo, st

	hi = 2000000
	lo = 2010000
	st = 1000
	
	for i = hi to lo by st do

		printf(1,"\nFor %d elements...\n",{i})	
		s = {}
		
		for t=1 to i do
			s &= rand(i)
		end for
	
		z = time()
		x = s/100
		puts(1,"\ts/100 seq op = ")
		?time() - z
		
		z = time()
		for t=1 to length(s) do
			s[t] = s[t]/100
		end for
		puts(1,"\ts/100 loop   = ")
		?time() - z

	end for

	z = wait_key()


and the sequence ops were quite fast (that is, fast enough)...
at most 2 hundredths of a second slower. So, maybe there has been some
optimization? Even for 5000000 elements, the difference was still in
hundredths of a second. I'm surprised! Delightfully so! :)

Sequence ops aren't that slow anymore...? Were they in the past? Rob?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu