h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
311 stars 23 forks source link

Preferred method of concatenating strings? #11

Closed mwgkgk closed 6 years ago

mwgkgk commented 6 years ago

What is the preferred method of concatenating two strings? Should we format them using interpolate? Is it reasonable to ask for concat-str? Maybe something I overlooked? Thank you :)

h3rald commented 6 years ago

I was debating on whether to add something like that or not... at present there is interpolate (%) but also join:

 (“This” “is” “a” “test”) “ “ join

It’s not as easy as a concat but it lets you customize the separator...

mwgkgk commented 6 years ago

("asdf" "bsdf") "" join seems reasonable! Concat would only be 1 argument shorter.

ghost commented 3 years ago

You can define a symbol for concatenating. I'll show you how:

( symbol combine
  (quot :elems ==> string :result)
  (elems "" join @result)
) ::

OR

( =elems
  elems (quot) expect
  -> "" join
) :combine

Use it like: ("asd" "fgh") combine puts It puts "asdfgh".