Global names in dfns
2 posts
• Page 1 of 1
Global names in dfns
Is the following behaviour to be expected?
)clear
clear ws
input←?15 15⍴9
+/,input
1111
{p←⍵ ⋄ {p×+/,⍵}input}2 3 4
2222 3333 4444
f←{p×+/,⍵}
{p←⍵ ⋄ f input}2 3 4
VALUE ERROR: Undefined name: p
f[0] f←{p×+/,⍵}
∧
- mikepowell
- Posts: 6
- Joined: Thu Dec 05, 2013 8:01 pm
Re: Global names in dfns
Yes this is normal.
The p referenced inside f has to be in the same lexical scope as that in which f is itself defined.
The p referenced inside f has to be in the same lexical scope as that in which f is itself defined.
{p←⍵ ⋄ f←{p×+/,⍵} ⋄ f input}or
{f←{p×+/,⍵} ⋄ p←⍵ ⋄ f input}would work.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group