Jacques Gélinas on Sun, 14 Oct 2018 17:56:25 +0200


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

RE: How to do Cartesian products in GP


Here is an example of the use of the outer product for sieving a list of prime numbers,
from the APL program (~R∊R∘.×R)/R←1↓ιR    or   (~R<-Ro.xR)/R<-1 drop iota R
which is interpeted after reading from right to left
https://en.wikipedia.org/wiki/APL_(programming_language)#Prime_numbers

R = 10;
R = [2..R];                 \\ R<-1 drop iota R
RR = [ a*b | a<-R; b<-R ];  \\ Ro.xR
setminus(R,Set(RR))         \\ Set(RR) needed here instead of RR

Jacques Gélinas