hermann on Sun, 10 Sep 2023 19:03:33 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Manually transpile Python code to GP: what about class / __name__ ?


On 2023-09-10 15:03, Bill Allombert wrote:
The whole problem is that this does not allow to change RSA.

? RSA.set=x->RSA[1]=x
%1 = (RSA)->x->RSA[1]=x
? RSA=[0,0];
? RSA.set(2)
%3 = 2
? RSA
%4 = [0,0]

Thanks, usecase does not need to change RSA, so member functions are good enough.


1)
Is it possible to define a member function without parameter?

you can do this
RSA.factored_2=()->{
...
}

2)
...
Is is possible to define default value for GP member function parameter
directly?
...
RSA.factored = (mod4=-1)->{
}
...
3)
I did not need sofar, but is it possible to pass multiple parameter"s to GP
member function?
(this likely does not make sense for what GP member functions have been
implemented)

You can do
RSA.fun=(x,y)->{...
}
If this is what you have in mind.

Thanks for all proposals, I changed repo accordingly with this commit:
https://github.com/Hermann-SW/RSA_numbers_factored/commit/402708433a0b2e16d82958535731d1fcd9546c4f


Regarding passing two parameters, I did that in 1st of new member function shortcuts:

RSA.to_squares_sum=(sqrtm1, p)->{
\\  """ shortcut """
    to_squares_sum(sqrtm1, p);
}

RSA.to_sqrtm1=to_sqrtm1;
\\  """ shortcut """


Regards,

Hermann.