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
|
- To: "pari-users@pari.math.u-bordeaux.fr" <pari-users@pari.math.u-bordeaux.fr>
- Subject: RE: How to do Cartesian products in GP
- From: Jacques Gélinas <jacquesg00@hotmail.com>
- Date: Sun, 14 Oct 2018 15:56:21 +0000
- Accept-language: fr-CA, en-US
- Delivery-date: Sun, 14 Oct 2018 17:56:25 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SuJQxIMclFxxYnFn8aDHqFqDVNF6Kv4Snru8WIOhEWM=; b=MFc2p+QADl8x1bdEsD53C+Ye+vpsVf+VRwMHqo/rSEDrisNG98giSdrfkuXzKaPObsDPWzeWeYM8nMwr6Qq5FFlvPIfks7vrDwpvmEWho6oDNbNSrTwTt2vg4IqqIU/Ae3CAHb/aWJ+KmDUtn8NQLGoeqSe3KKAlc1B41Oxcpk9JEY6UWH9iX42qaD/BNSUyW4EKQp+EjNfCnrzjcA4G2/Lvs/pq1wAVq4pVoybivQOg0o2gLY/6IPuyqivcrVwefqJLxV62MJ/zuzjDd8NERco5Vc6Waw82BHtanOqBwtggwPAKBE4H0QbLU1dHI66OYqPTPoJqFMubNOgUPUm+8w==
- In-reply-to: <20181007200807.zy7wbyt6m2mhqpkc@yellowpig>
- References: <20181007200807.zy7wbyt6m2mhqpkc@yellowpig>
- Thread-index: AQHUXnl8phbCEJCrJ0SdaVU128GKvKUe51LL
- Thread-topic: 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