How to execute a variable
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
4 posts
• Page 1 of 1
How to execute a variable
I don't know what this is called, but I think it's possible in APL. Let's say I have matrixes with for example, calendar data, called CAL2020, CAL2021, CAL2022, and I have a function that I call with a year value for Y, for example PLOTCALENDAR 2021. So when the function is called, Y will have a value such as 2021, 2022, etc. I then want to read from the matrix for that year, such as CAL2021. I believe there is a way to access the variable using by piecing together 'CAL' and Y. Does anyone know? Thanks.
- lancepawl
- Posts: 10
- Joined: Tue Sep 05, 2017 1:43 pm
Re: How to execute a variable
You used the right word in your subject line.
You want the "execute" primitive ⍎.
If your Y is a character vector like '2021', then you want
M←⍎'CAL',Y
If your Y is an integer like 2021, then you want
M←⍎'CAL',⍕Y
You want the "execute" primitive ⍎.
If your Y is a character vector like '2021', then you want
M←⍎'CAL',Y
If your Y is an integer like 2021, then you want
M←⍎'CAL',⍕Y
- rex
- Posts: 12
- Joined: Sat Jun 10, 2023 10:49 pm
Re: How to execute a variable
Hello,
If Y is an integer, a simple answer is :
⍎'CAL',⍕Y
--
Yves-Antoine Emmanuelli.
If Y is an integer, a simple answer is :
⍎'CAL',⍕Y
--
Yves-Antoine Emmanuelli.
--
Yves-Antoine Emmanuelli
Yves-Antoine Emmanuelli
-
yaemmanuelli - Posts: 16
- Joined: Sat Aug 01, 2020 6:29 pm
- Location: Recloses, France
Re: How to execute a variable
Thanks very much for the answers! I appreciate it.
Regards,
Lance
Regards,
Lance
- lancepawl
- Posts: 10
- Joined: Tue Sep 05, 2017 1:43 pm
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group