1. optimization for equal_shape()

We don't seem to have this function in the standard library. If we do, I can't find it. Maybe that's because we don't need one, but it is handy.

Please provide optimizations (or a better algorithm)...

function equal_shape( object a, object b ) 
	if atom(a) then 
		if atom(b) then		-- a and b are atoms 
			return 1 
		else 
			return 0		-- a is atom, b is sequence 
		end if 
	elsif atom(b) then		-- a is sequence, b is atom 
		return 0 
	end if 
 
	-- both a and b are sequences 
	a *= 0 
	b *= 0 
	 
	return equal(a,b) 
end function 
new topic     » topic index » view message » categorize

2. Re: optimization for equal_shape()

Doesn't this have the same result?

function equal_shape( object a, object b ) 
	return equal(a * 0, b * 0) 
end function 
euphoric said...

We don't seem to have this function in the standard library. If we do, I can't find it. Maybe that's because we don't need one, but it is handy.

Please provide optimizations (or a better algorithm)...

function equal_shape( object a, object b ) 
	if atom(a) then 
		if atom(b) then		-- a and b are atoms 
			return 1 
		else 
			return 0		-- a is atom, b is sequence 
		end if 
	elsif atom(b) then		-- a is sequence, b is atom 
		return 0 
	end if 
 
	-- both a and b are sequences 
	a *= 0 
	b *= 0 
	 
	return equal(a,b) 
end function 
new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu