[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] using a custom function in classes
- To: sc-users@xxxxxxxxxxxxxxxx
- Subject: Re: [sc-users] using a custom function in classes
- From: James Harkins <jamshark70@xxxxxxxxx>
- Date: Fri, 8 May 2009 10:27:11 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=sntebSqGXTgHBedqCaLv73TvpBBqwRK6wmN9HuAaVpk=; b=GJRugfAvFmFgq+tr1gz++G698nH5X75Ya6HQqBax6D+pKZuHePDkxDltxeAHKkE5UP przwTVldJocbNA1TvA8MMYQMtQ+txG/lzh/fDFieooYUZlE2NhraHdkhD8LXBmi8+KEI DGhTPsGDqNnGHUin4CwclIW0jEvcrnyl2oDt4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; b=Blnna3uh/YgRCT+pfclO+FiEY8jgdQpDt5iZQPUgINjtBzADfYIg1/d/7dLz8M7hjK hpbeknhYejdmtrLw7Y6MoSyz4px+RcTNKXCVz1GY1d+ebOztPklPXVB2Pg8u/4TPotj/ +X+0NRnkJjyvGB60bqSt2TOzjMhRqYFtV8Zbc=
- In-reply-to: <BAY109-W4018AE8918E038DE08174199640@xxxxxxx>
- List-id: SuperCollider users mailing list <sc-users.create.ucsb.edu>
- References: <BAY109-W4018AE8918E038DE08174199640@xxxxxxx>
- Reply-to: sc-users@xxxxxxxxxxxxxxxx
- Sender: owner-sc-users@xxxxxxxxxxxxxxxx
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/