Play Matchmaker
Problem
Romeo is an NS GSOH M Veronian (nonsmoking, good-sense-of-humor male who lives in Verona). Juliet WLTM (would like to meet) an NS GSOH M. Will Romeo do?
The Suitor table shows the names of each suitor:
Name |
---|
Romeo |
Paris |
The Has table (Table 7-17) shows their qualities:
Name | Has_quality |
---|---|
Romeo | NS |
Romeo | GSOH |
Romeo | Veronian |
Romeo | M |
Paris | NS |
Paris | M |
…… |
The Wltm table shows the features that Juliet demands:
Name | QUALITY |
---|---|
Juliet | NS |
Juliet | GSOH |
Juliet | M |
Please find the suitors having all three qualities that Juliet required.
Tip
General steps: You can retrieve the qualities of each suitor first, and then cycle every suitor to compare each suitor’s qualities against the features demanded by Juliet. Finally, return the list of persons with the required qualities.
Code
A | ||
---|---|---|
1 | =file("C:\\txt\\Suitor.txt").import@t() | |
2 | =file("C:\\txt\\has.txt").import@t() | |
3 | =file("C:\\txt\\Wltm.txt").import@t() | |
4 | =A2.group(Name) | Group suitos by name |
5 | =A3.select(Name=="JULIET").(QUALITY) | Qualities required by Juliet |
6 | =A4.select(~.(Has_Quality).pos(A5)!=null) | Group of suitors meets Juliet ‘s demand |
7 | =A6.(Name) | Return the name list of suitors meeting the requirement |
Result
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL
Chinese version
Data files
has.txt
Suitor.txt
Wltm.txt