associative appending operator in swift,
infix operator <~ { associativity left }
func <~<elem> (var list:[elem], elem:elem) -> [elem] {
list.append(elem)
return list
}
[1, 2, 3] <~ 4
//[1, 2, 3, 4]
[1, 2, 3] <~ [5]
//[1, 2, 3, [5]]
//due to associativity being left, the operands are all push to the list on the left
[1] <~ [2] <~ [3]
//[1, [2], [3]]
[1] <~ 2 <~ 3 <~ 5
//[1, 2, 3, 4]