|
That's a very good suggestion actually. thanks! > From: lfsaw@xxxxxxxx > To: sc-users@xxxxxxxxxxxxxxxx > Subject: Re: [sc-users] using a custom function in classes > Date: Fri, 8 May 2009 16:53:46 +0200 > > Hey, > > you may want to create a class collecting such functions as classmethods > > MyFunctions { > *nthFactorial {...} > } > > which you then can use from within other Classes: > > B { > b { > ^MyFunctions.nthFactorial(); > } > > } > > lg + hope that helps > Till > > On 08.05.2009, at 16:27, James Harkins wrote: > > > The only way (I'm fairly sure) is to pass the function into the method > > as an argument. > > > > Your function exists outside the lexical scope of the class, so there > > is no way for it to know about the func magically. > > > > calc { arg x, func; > > ... > > } > > > > myThing.calc(100, myFactorialFunction) > > > > hjh > > > > On Fri, May 8, 2009 at 10:24 AM, Michael Dzjaparidze > > <m_dzjaparidze@xxxxxxxxxxx> wrote: > >> Hello, > >> > >> I've made a function that returns the nth factorial and I need to > >> use it in > >> a couple of different classes I'm writing. My question is... How do > >> I do > >> this? Inside a class I want to be able to do something like: > >> > >> //Instance method in a class to do some calculation -> > >> MyClass.calc(100) > >> calc { arg x; > >> var a, b, c; > >> > >> a = someCalculationOnX * (6, 2)nthfactorial // > >> Meaning 1 > >> * 2 * 4 * 6 and nthfactorial is my custom function > >> ^a; > >> } > >> > >> Maybe the answer is really obvious, but I don't see how to do it. I > >> would > >> appreciate it very much if somebody can help me. > > > > > > -- > > James Harkins /// dewdrop world > > jamshark70@xxxxxxxxxxxxxxxxx > > http://www.dewdrop-world.net > > > > "Come said the Muse, > > Sing me a song no poet has yet chanted, > > Sing me the universal." -- Whitman > > > > _______________________________________________ > > sc-users mailing list > > > > info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml > > archive: https://listarc.bham.ac.uk/marchives/sc-users/ > > search: https://listarc.bham.ac.uk/lists/sc-users/search/ > > > _______________________________________________ > sc-users mailing list > > info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml > archive: https://listarc.bham.ac.uk/marchives/sc-users/ > search: https://listarc.bham.ac.uk/lists/sc-users/search/ Haal meer uit je Hotmail met Internet Explorer 8. Download nu |