Numbas Error: Equality not defined for type lambda

5 views
Skip to first unread message

William Haynes

unread,
Apr 3, 2026, 12:57:03 PMApr 3
to Numbas Users
For convenience i have been using lambda functions to format quantities the way I want them to appear, for example

force = f -> siground(qty(f, unit),3)

If I use the lambda function as the correct value for a quantity gap, I see the error under the testing tab for the gap.   Otherwise things work just fine.


Will

Christian Lawson-Perfect

unread,
Apr 14, 2026, 6:10:52 AM (9 days ago) Apr 14
to numbas...@googlegroups.com
The error arises when the editor tries to decide whether to regenerate the question instance used for testing. It compares the values of all variables against the last ones it used and gives up if they're all the same. Equality isn't defined for anonymous functions, so an error is thrown.

I've changed it to skip over values that don't have a defined equality method. I can only see that causing a problem if you have no random variables but somehow make a change to the value of an anonymous function by other means.

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/numbas-users/f6c1054d-7f28-4052-b680-1189d48e893dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages