# This query returns FALSE
once(call("member", 1, list(quote(a), quote(b), quote(c))))
# This query returns an empty list meaning yes, it works
once(call("member", 3, list(1, 2, 3)))
# This query returns a list stating that it works if X = 1
once(call("member", 1, list(quote(a), expression(X))))
# The same query using simplified syntax
q = quote(member(1, ""[a, .X]))
once(as.rolog(q))
# This query returns a list stating that X = 1 and Z = expression(Y)
once(call("=", list(expression(X), expression(Y)), list(1, expression(Z))))
# This works for X = [1 | _]; i.e. something like [|](1, expression(_6330))
once(call("member", 1, expression(X)))
# This returns S = '1.0' (scalar)
once(call("format", call("string", expression(S)), "~w", list(1)), options=list(scalar=TRUE))
# This returns S = '#(1.0)' (vector), because the 1 is translated to #(1.0).
# To prevent "~w" from being translated to $$("~w"), it is given as an atom.
once(call("format", call("string", expression(S)), as.symbol("~w"), list(1)),
options=list(scalar=FALSE))
Run the code above in your browser using DataLab