Post AtZyZBvemD9clXIcNs by dpiponi@mathstodon.xyz
(DIR) More posts by dpiponi@mathstodon.xyz
(DIR) Post #AtZyZBvemD9clXIcNs by dpiponi@mathstodon.xyz
2025-04-28T20:30:26Z
0 likes, 0 repeats
A bunch of languages have a kind of array (which might not be fully reified) whose main purpose is to be expanded out as individual subexpressions in a larger expression.In Python we have *a where a is an array. So we can writea = [1,2,3]print(5, *a)and it's the same as print(5,1,2,3).In C++ we have parameter packs so we can do things liketemplate<typename... Ts> using Type = std::tuple<int, Ts..., float>;And in Mathematica we have Sequence[] that allows things like:x=Sequence[10,20,30];f[1,x,3,4]Out[1]=f[1,10,20,30,3,4]I think Python's *a isn't really an object at all, just a syntactic trick, but a is a proper list of course.Parameter packs only quasi-exist. For example you can't pass one as a template argument without triggering its expansion with ... and a template can't (without some wrapping) accept two parameter pack arguments. But you can operate on them, eg. with folds.Mathematica's Sequence is a fully fledged Mathematica object but trying to examine one is tricky because (like in C++) attempts to pass it to a function expand it first. It's "unstable" in the sense that it expands itself without a * or ... .What are other examples?
(DIR) Post #AtZyZDDPzexKkucJhw by akater@shitposter.world
2025-04-29T09:41:50.503848Z
0 likes, 1 repeats
@dpiponiLisp has UNQUOTE-SPLICE but, unlike Mathematica's Sequence, it is• erroneous to eval outside of quasiquote• may not even be an actual expression; in standard Common Lisp, quasiquotes and their unquotes are resolved at read timeThe standard syntax for it is ,@ or ,. (the latter is destructive; a.k.a. UNQUOTE-NSPLICE).