Throwaway comment in Hazrat p105:
Observe that Range[10]/.{x_,y___}->y/x
amounts to 10!
I can't for the life of me figure out how this works.
It seems to resolve to Sequence[2,3,4,5,6,7,8,9]/1
which then defaults to Times[2,3,4,5,6,7,8,9]/1
which seems like odd behaviour.
I checked the documentation but this doesn't resemble their examples of a sequence being ready to splice into another function.
Any comments?
Range[10] /. {x_, y___} -> FullForm[HoldComplete[y/x]]
. In general, when in doubt as to how things are evaluated, look at itsFullForm[]
. $\endgroup$ – J. M.'s ennui♦ Apr 6 '17 at 3:36Sequence[2,3,4,5,6,7,8,9]/1
is reallyTimes[Sequence[2,3,4,5,6,7,8,9], Power[1, -1]]
behind the scenes, which is the same asTimes[2,3,4,5,6,7,8,9, Power[1, -1]]
. The point is thata/b // FullForm
isTimes[a, Power[b, -1]]
. $\endgroup$ – march Apr 6 '17 at 3:38