The problem with that approach is things like f=:f+1 are usually applied to a 
temp variables, meaning in a local context.

IOW, normally what's wanted is f=.f+1 (not =:), of course explicit definitions 
cannot manipulate the local names within other explicit definitions.  This is 
one reason I prefer tacit coding where I can get it.  

In this case, I might take a hybrid approach, and have your modf produce a 
string, which will subsequently be executed (with monad ".) in the local 
context of the calling definition.

Something along these lines:


modf2=: (1 :0) (".@:)
  dyad def ' ''('',x,''~)=:(".'',x,'') '' <@:(5!:6)">&.;:''u y'' ' 
)

Though I haven't tested (I'm on a blackberry).

-Dan

Please excuse typos; composed on a handheld device.

-----Original Message-----
From: Raul Miller <rauldmil...@gmail.com>
Date: Wed, 21 Apr 2010 12:39:54 
To: Programming forum<programming@jsoftware.com>
Subject: Re: [Jprogramming] f += 1

For what it's worth, here is how to define, in J, a
word which parallels C's modified assignment
operations:

modf=:1 :0
:
  (x)=:(".x)u y
)


Its use pattern is:

   quotedname verb modf noun

Its meaning is:
   name =: name verb noun

where name is the name which was quoted.

For example:
   N=:10
   'N' + modf 3
   'N' * modf 2

N will have the value 26 after executing these lines.

If any of this needs explaining, please let me know.

FYI,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to