-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Maxima structures (and their @
field access operator) in question variables
#1068
Comments
Currently forbidden, but unlike in older STACK versions, we do not have impossible technical constraints for allowing this. The constraints are more related to author-side debugging messages and how those should represent things. One reason why these might still have some issues in our world is this:
Basically, from the outside, it is difficult to distinguish between structs and function calls. As to alternativesThe approach I think is most used is the so-called inert function, like
In general, lists have proved to be very useful, especially if one knows how to unpack them using that multi-assign operator like on the second line of the example. However, every now and then people need to have maps/dictionaries, and as not everyone is aware of the way the handy As to functions returning many things, I think that returning a list is the STACK way of doing things, even our answer tests follow that pattern:
Naturally, if it returns a massive number of things you cannot unpack them selectively in that assignment. Either unpack all or take the result as a list and pick some from that. As to structsThe path for them to become a thing in STACK is as follows, and I don't really see how it would fit our current development plans as it does not really connect to any of the things in movement currently. But I will keep my eyes open to avoid them becoming impossible again.
Of those number 3 is probably the one that would require the most work. |
Thank you very much for the detailed answer. Actually, I have been using list unpacking already, but as some of my functions would return lists with dozens of elements, relying on the order of items in the list quickly becomes tiresome and the code is difficult to read. Also, assuming I get it right, each variable name used in unpacking needs to be listed in the I will look at the alternatives you mentioned. It would be nice to have the possibility of using structs sometime in the future. Thank you for your help and your work on this great tool! |
Hello,
What I want to achieve
I have several functions that should return structured data that I want to access in a key-value manner. I tested Maxima structures (https://maxima.sourceforge.io/docs/manual/maxima_singlepage.html#Structures) to achieve that and they work fine in my local Maxima setup.
Problem
The problem is that Maxima structures use a
@
field access operator, which seems not to be allowed in question variables field. This is the error I get: The characters @, $ and \ are not allowed in CAS input.Question
So I would like to ask if there is any way to make Maxima structures work in STACK, or is there any recommended workaround, supported datatype and/or syntax for the scenario where I have more than 10 values to be returned by a function?
Example
Minimum working (in my local Maxima setup) and non-working (in question variables of a Moodle STACK question) example is:
The text was updated successfully, but these errors were encountered: