Recycling what I've already offered:

NB. single-line (with luck!) explicit form:
pmtex =: 3 : 'b * r * incrtot % <: incrtot =. t^~ >: r =. 1200 %~ {. ''r t b'' =. y'

NB. in case line-wrapping spoils the above,
NB. here's a version avoiding unnecessary spaces:

pmtex0sp =: 3 : 'b*r*incrtot%<:incrtot=.t^~>:r=.1200%~{.''r t b''=.y'

NB. Tacit version using tie ( ` ) with insert:
pmtac =: *`(]*(%<:)@ (^~>:))/@:(1 1 1200%~|.)

NB. This alternative avoids the dreaded atop and at:
pmtac0at =: [: (*`(] * [: (% <:) (^~ >:))/) 1 1 1200 %~ |.

rtb  =: 5.75 240 12500
   (pmtex, pmtex0sp, pmtac, pmtac0at) rtb
87.7604 87.7604 87.7604 87.7604

Any use?

Mike
PS - I've snipped the history previous to Linda's first amortisation post.


On 13/09/2018 15:34, Linda Alvord wrote:
Here  are two tacit verb for pmt from Raul,


pmt1200=:(%<:)@D * 1 0 1 */ .# ]
    pmt=: pmt1200@(%&1200 1 1)
    pmt 5.75 240 12500
87.7604
D
[: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]
pmt1200
(% <:)@D * 1 0 1 */ .# ]
Can anyone other than Raul or Rob) writ an explicit OR tacit single sentence definition for:

PMREX=:

PMTTA=:

Cheers, Linda

(Raul and Bob can coach tacits and I'll respond to explicits)
Try 5.75 240 12500

-----Original Message-----
From: Programming <programming-boun...@forums.jsoftware.com> On Behalf Of 'Rob 
Hodgkinson' via Programming
Sent: Thursday, September 13, 2018 2:23 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Tacit form: How to handle intermediate

Ahh I’m sorry Linda, that was my bad copy/paste into the email …

Please ignore previous email, I have corrected the transcript below (and 
verified) so this should run without conflict (aside from being careful of 
quotes on copy/paste perhaps):

Raul’s functions:
    D=:[: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]
    pmt1200=:(%<:)@D * 1 0 1 */ .# ]
    pmt=: pmt1200@(%&1200 1 1)
    pmt 5.75 240 12500
87.7604

My revised input for 13 : is also included here, as I had a mis-copy there too.
    Da=:13 : '(^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* y’          NB. Removed the 
leading [: as not required for explicit (I could have left it in, but I’m trying 
to exactly reproduce Raul’s tacit definitions above), and added last term y to the 
explicit expression
    pmt1200a=: 13 : '((%<:)@Da y) * 1 0 1 */ .# y’   NB. Added last term y to 
the first and last “tine” of the fork Raul produced
    pmta=: 13 : 'pmt1200a@(%&1200 1 1) y’          NB. Added last term y 
(although this is not required as composition can be applied directly as Raul did 
without requiring explicit)

NB. Let’s compare to Raul’s solution in email below ...
    Da
[: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]                           NB. Same 
definition as Raul above
    pmt1200a
(% <:)@Da * 1 0 1 */ .# ]                                       NB. Same
    pmta
pmt1200a@(%&1200 1 1)                                    NB. Same

    pmta 5.75 240 12500
87.7604                                                                 NB. 
Results match


Sorry if I confused with previous transcript paste.

…/Regards Rob


On 13 Sep 2018, at 3:21 pm, Linda Alvord <lindaalvor...@outlook.com> wrote:

Here's a problem.  I'm not having trouble with cut and paste so could you show 
the working version.

Also do not remove caps  [: from tacit results as they are needed for the 
explicit versions you are writing to work correctly.


D=:[: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]
   pmt1200a=:(%<:)@Da * 1 0 1 */ .#
|value error: Da
|   pmt1200a=:    (%<:)@Da*1 0 1*/ .#
|[-1] c:\users\linda\j64-807-user\temp\15.ijs



Linda

-----Original Message-----
From: Programming <programming-boun...@forums.jsoftware.com> On Behalf
Of 'Rob Hodgkinson' via Programming
Sent: Wednesday, September 12, 2018 11:26 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Tacit form: How to handle intermediate

Hi Linda, Raul’s functions may be input to 13: as shown here:

Raul’s functions:
   D=:[: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]
   pmt1200a=:(%<:)@Da * 1 0 1 */ .#
   pmta=:pmt1200@(%&1200 1 1)
   pmta 5.75 240 12500
87.7604

Revised as input to 13 :  (note in the below the space required between ’13’ 
and ‘:’ and that I have “removed” any tacit addons (such as [:) to exactly 
reproduce Raul’s tacit definitions ...
   Da=:13 : '(^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* y’               NB. Removed the 
leading [: as not required for explicit (I could have left it in, but I’m trying 
to exactly reproduce Raul’s tacit definitions above), and added last term y to the 
explicit expression
   pmt1200a=: 13 : '(%<:)@Da * 1 0 1 */ .# y’             NB. Added last term y
   pmta=: 13 : 'pmt1200@(%&1200 1 1) y’                 NB. Added last term y 
(although this is not required as composition can be applied directly as Raul did) 
without requiring explicit)

NB. Let’s compare to Raul’s solution in email below ...
   Da
[: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]                                NB. Same 
definition as Raul
   pmt1200a
[: (% <:)@Da [: * 1 0 1 */ .# ]                                      NB. Same
   pmta
pmt1200@(%&1200 1 1)
  pmta 5.75 240 12500
87.7604

HTH but if still unclear please expand ?

For further reference re [: only having meaning in tacit form (which is why I 
removed it for explicit form) it may be helpful to read this link:
        
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcode
.jsoftware.com%2Fwiki%2FVocabulary%2Fsquarelfco&amp;data=02%7C01%7C%7C
c059f09bd44446fc424708d61928c374%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C
1%7C0%7C636724060199447363&amp;sdata=OrnLHRv1N%2Fe5lnADLmIGobGEQkw5kxY
mbnHMVx84AIs%3D&amp;reserved=0
<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcod
e.jsoftware.com%2Fwiki%2FVocabulary%2Fsquarelfco&amp;data=02%7C01%7C%7
Cc059f09bd44446fc424708d61928c374%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7
C1%7C0%7C636724060199447363&amp;sdata=OrnLHRv1N%2Fe5lnADLmIGobGEQkw5kx
YmbnHMVx84AIs%3D&amp;reserved=0>

Thanks, Rob


On 13 Sep 2018, at 1:05 am, Linda Alvord <lindaalvor...@outlook.com> wrote:



When you'e're done f=: 13  :'...

enter
f

If the result is tacit there will be no x or y.  Instead you get a string of  
separate J symbols which J uses from right to left to follow your instructions.

I need a laptop to check. Raul's function.

Linda



'

Sent from my Verizon, Samsung Galaxy smartphone
-------- Original message --------
From: Raul Miller <rauldmil...@gmail.com
<mailto:rauldmil...@gmail.com>>
Date: 9/10/18 12:55 AM (GMT-05:00)
To: Programming forum <programm...@jsoftware.com
<mailto:programm...@jsoftware.com>>
Subject: Re: [Jprogramming] Tacit form: How to handle intermediate

x=:0 is bad form, so I am going to ignore that part.

In fact, I'd eliminate all internal =: from that definition and start with:

pmt=: 3 : 0
0 pmt y
:
'r t b'=. y
D=.(1 + r % 1200) ^ t
b*(r % 1200) * D % D - 1
)

And our paranoia test is:
  pmt 5.75 240 12500
87.7604

The next issue is that we're working with more than two values, that
makes it a bit complicated.

On the other hand, we never use x - if it's provide we ignore it. So
I'm going to ignore it here. If that bothers you, use pmt=: pmt&] f.
after we've got the tacit expression. (Using f. on the final
expression will also protect from some damage if you happen to run
the original with it's D=: expression...).

Anyways...

To simplify this slightly, notice that we never want to use the value
of r. Instead, we always want r%1200. So we can divide y by 1200 1 1
and work the remainder of the dyadic expression becomes:

pmt1200=: 3 : 0
'r t b'=. y
D=.(1 + r) ^ t
b*r * D % D - 1
)

A tacit expression to compute D directly from this y would be:
  D=:  [: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]

with that definition of D, pmt1200 can be
  pmt1200 =: (%<:)@D * 1 0 1 */ .# ]

and our tacit pmt becomes
  pmt=: pmt1200@(%&1200 1 1)

Trying it out:
  pmt 5.75 240 12500
87.7604

Good enough?

--
Raul
On Sun, Sep 9, 2018 at 9:55 PM Linda Alvord <lindaalvor...@outlook.com 
<mailto:lindaalvor...@outlook.com>> wrote:
Here's a classic. Can anyone write this in tacit?

NB. Mortgage is Rate Months Loan

pmt=: 3 : 0
(x =: 0) pmt y
:
'r t b'=:y
D=:(1 + r % 1200) ^ t
b*(r % 1200) * D % D - 1
)

pmt 5.75 240 12500

In 1961 I bought a house for $17,000. With a loan of $12,000 at 5.75 interest 
for 20 years. As a tenured teacher and a woman no bank would give me a mortgage 
but for 20 years I payed the previous woman owner $87.77. At the last payment 
it just so happened that I sold it.

Linda




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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

Reply via email to