ThakeeNathees / pocketlang

A lightweight, fast embeddable scripting language.
https://thakeenathees.github.io/pocketlang/
MIT License
1.52k stars 80 forks source link

[Enhancement] Add List.join(sep="") method. #260

Open khchen opened 2 years ago

khchen commented 2 years ago

Also add separator as an optional argument to builtin list_join().

[1, 2, 3].join(',') looks better than list_join([1, 2, 3], ','). However, list_join() is used in string interpolation, and builtin function is faster than method call. So keep builtin list_join() but add a new method to List class.

Example:

print([1, 2, 3].join())
print([1, 2, 3].join(', '))

Output:

123
1, 2, 3