1. optimization for equal_shape()
- Posted by euphoric (admin) Dec 22, 2010
- 1179 views
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
2. Re: optimization for equal_shape()
- Posted by jimcbrown (admin) Dec 22, 2010
- 1131 views
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