| Bill Allombert on Thu, 17 Aug 2023 14:04:37 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: New gp features |
On Sun, Aug 13, 2023 at 08:39:18PM +0200, hermann@stamm-wilbrandt.de wrote:
> Few questions:
>
> A) foreach cannot be redefined?
>
> foreach2(a,b,c) = foreach(a,b,c);
This does not work, because user GP functions are 'strict':
b and c are evaluated before foreach2 is evaluated to a closure.
Instead you can do
foreach2(a,c) = foreach(a,b,c(b))
and then
foreach2(a,t->printf("%d ",t[1]))
> B) foreach variable cannot be multi assignment tuple?
>
> ? foreach(rsa,[l,n],printf("%d ",l));
> *** variable name expected: foreach(rsa,[l,n],printf("%d ",l));
> *** ^-----------------------
No, this is not supported.
> C) holes only allowed on LHS, not on RHS?
>
> ? [a,b,c] = [1,2]
> *** at top-level: [a,b,c]=[1,2]
> *** ^--------
> *** nonexistent component: index > 2
c would not be defined.
Cheers,
Bill