Alternatively, a version that uses a single method chain with no temporary variables: (Same output with same input)
submode (*@a) { @a.Bag # count elements .classify(*.value) # group elements with the same count .max(*.key) # get group with the highest count .value.map(*.key); # get elements in the group}say mode [1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17];say mode [1, 1, 2, 4, 4];