MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: argument passing


Hi,

if You give the function the attribute HoldFirst or HoldAll the
arguments are not evaluated and so the list mylist is not expanded to
its value {1,2,3,..}
As an example

SetAttributes[ListElementDifference,HoldFirst]
ListElementDifference[l_List,n1_Integer,n2_Integer]:=l[[n2]]-l[[n1]]

will  not create a copy of the value of l.

Hope that helps
  Jens
-----Original Message-----
From: Morten N. Aasnes <mortena at vipe.ii.uib.no> To:
mathgroup at smc.vnet.net
Subject: [mg14146] [mg14110] argument passing


>How does mathematica pass arguments to functions? If I have a realy
>large list, and make a function to take a list as argument, and return
>a certain element, will the list given as argument be copied when the
>function is called, and if so, how do I avoid this?
>
>thanks in advance.
>
>--
>Morten Nygaard Aasnes     mortena at ii.uib.no       "Nothing's the same
>anymore" Fantoft Stud.By A626,     (+47)55276131            -Sinclair
>in b5:"Chrysalis" N-5036 FANTOFT, NORWAY    www.ii.uib.no/~mortena
><*>
>
>



  • Prev by Date: Re: Field of Functions
  • Next by Date: Re: Compiled programs
  • Previous by thread: argument passing
  • Next by thread: Conditionals ("If") and definitions for 3D plots