@Razetime TCO is pretty fun to implement--it's basically a rewriting pass in your evaluate function, repeated until it's not possible to rewrite the expression any further.
@user I do remember that, but that's not the message I was replying to. ;)
@Giuseppe Yeah, Int is a library shortcut for (q Int). Depending on what types you're comparing, you can also do some hacky stuff with builtins, since passing the wrong types to a builtin prints an error message but also returns nil.
@Giuseppe So in this case, since you have either a list or a positive integer, you can replace (e(type(h L))(q Int)) with (a(h L)1): positive integer (truthy) if (h L) is an integer, or nil (falsey) if it's a list.
@Giuseppe Since your second answer is on a challenge I've previously answered, I can't give it a 50-point bounty. Is it okay if I bounty your first answer instead?