comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: brain twister
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: brain twister [message #22808 is a reply to message #22806] Fri, 08 December 2000 08:58 Go to previous message
mole6e23 is currently offline  mole6e23
Messages: 31
Registered: December 1998
Member
craigmnet@cow.physics.wisc.edu wrote:

> Okay, enough ideology for one week. Here are some brain twisters for
> you. See if you can decide what the output should be without running
> it. In each example I give the commands to paste into the command
> line, ending with some main-level commands to enter.

I was able to guess number two, but I never would have guessed at number
one. I'm assuming this is some sort of memory saving device? I notice that
if you pass a,a+1 you get something different, which, after having seen
the results of example 1, you might be able to expect.

Look at the two following examples for another interesting behavior
(although not quite as interesting by any means!):

;; begin
.comp
pro test1, x, y, z
help, y, x, z
end

.comp
pro test2, y, x, z
help, z, y, z
end

a=dindgen(5)
test1,a,a,a
test2,a,a,a
;; end

That surprised me a little at first, but I guess it makes sense. You have
to do something with your variables in the program.

I think example two makes a lot of sense...you are passing the parameter
directly. If you can modify x within the function/procedure, why not
actually return x?

Neat examples, though!

Todd

>
> ----- Example 1
> .comp
> pro test1, x, y
> help, x, y
> end
>
> a = dindgen(5)
> test1, a, a
>
> ----- Example 2
> .comp
> function test2, x
> return, x
> end
>
> a = dindgen(5)
> (test2(a))[2] = -2
> print, a
>
> These were a bit of a surprise for me!
> Craig
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: WNT environmental vars
Next Topic: IDLWAVE 4.6

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 12:26:17 PDT 2025

Total time taken to generate the page: 2.47785 seconds