On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

i know that lil has fuse, but how would i do something like `{x,"\n",y}/("hello";"world";"etc")` in k? i have a list of strings of arbitrary length and i want to combine them all into a single string by a delimiter. is there a way to do that?

(+1)

nevermind, i figured it out! somehow i missed that part of the lil docs.

(1 edit)

To use K terminology, fuse is a dyad which takes a delimiter as its left argument:

 "\n" fuse ("hello","world","etc")
"hello\nworld\netc"
  ":ANYTHING:" fuse ("hello","world","etc")
"hello:ANYTHING:world:ANYTHING:etc"

And you can handle even fancier cases with a recursive "format":

  (list "ITEM<%s>") format ("hello","world","etc")
("ITEM<hello>","ITEM<world>","ITEM<etc>")
  ("\n","ITEM<%s>") format ("hello","world","etc")
"ITEM<hello>\nITEM<world>\nITEM<etc>"