1. Window parameters
- Posted by mike <michael at IGRIN.CO.NZ>
Sep 29, 1998
-
Last edited Sep 30, 1998
Does anyone know how to get any Windows command line parameters?
ie: the 'options' that might be entered after the name of the executable
file in a Win95 shortcut. When I use command_line() it gives me a sequence
of length 2, always.
On another note here are some solutions for int using a trick noted on the
maximum/minimum round..
There must be even faster examples for specialized routines like int(atom
a) or int(sequence s) -- where s is one-dimensional
-- simple but not the fastest
function int(object a)
return floor(a)*(a>0) -floor(-a)*(a<0)
end function
-- faster, more complex and lends itself to explicit error checking
object temp
temp=a
function int_(object a)
if atom(a) then
if a<0 then return -floor(-a) else return floor(a) end if
else
for i=1 to length(a) do
temp[i]=int_(a[i])
end for
end if
return temp
end function
Yours Truly
Michael Palffy
michael at igrin.co.nz
2. Re: Window parameters
mike wrote:
>On another note here are some solutions for int
>using a trick noted on the maximum/minimum round..
> -- simple but not the fastest
> function int(object a)
> return (floor(a)*(a>0)) - (floor(-a)*(a<0))
> end function
okay, assuming you want int to behave differently
than floor, such that:
y = floor({0.5, -1.6, 9.99, 100})
y is {0, -2, 9, 100}
versus
y = int({0.5, -1.6, 9.99, 100})
y is {0, -1, 9, 100}
then below is where you get a wee 'screwy' :)
> -- faster, more complex, allows error checking
> object temp
> temp=a
> function int_(object a)
> if atom(a) then
> if a<0 then return -floor(-a) else return floor(a) end if
> else
> for i=1 to length(a) do
> temp[i]=int_(a[i]) --***temp not declared
> end for --not needed tho...
> end if
> return temp
> end function
you could change your function to read (abbreviated):
func int_(obj a)
if atom(a) then
if a<0 then ret -floor(-a) else ret floor(a) end if
else for i=1 to length(a) do
a[i]=int_(a[i])
end for
end if
ret a
end func
but... try this instead:
function ToInt(object a)
object tmp
if atom(a) then
if a<0 then
return -floor(-a)
else return floor( a)
end if
else
for i=1 to length(a) do
tmp=a[i]
--let's save recursing the innermost seq dimension
--if it's a 10000 len seq, you saved 10000 recursions
if atom(tmp) then
if tmp<0 then
tmp=-floor(-tmp)
else tmp= floor( tmp)
end if
else tmp=ToInt(tmp) --see? now we only recurse when
end if -- its *really* needed...
a[i]=tmp
end for
return a
end function
mebbe that'll run a wee better :)
--Hawke'