diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-09-22 07:04:10 +0000 |
---|---|---|
committer | <> | 2015-02-02 12:02:31 +0000 |
commit | 23c11479b3ad787adc7a651ee0c4347839e47723 (patch) | |
tree | 3aa9e1125da84f7e3bd764bbff577c42a766508b /examples/join.m4 | |
download | m4-tarball-master.tar.gz |
Diffstat (limited to 'examples/join.m4')
-rw-r--r-- | examples/join.m4 | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/join.m4 b/examples/join.m4 new file mode 100644 index 0000000..8687ac7 --- /dev/null +++ b/examples/join.m4 @@ -0,0 +1,15 @@ +divert(`-1') +# join(sep, args) - join each non-empty ARG into a single +# string, with each element separated by SEP +define(`join', +`ifelse(`$#', `2', ``$2'', + `ifelse(`$2', `', `', ``$2'_')$0(`$1', shift(shift($@)))')') +define(`_join', +`ifelse(`$#$2', `2', `', + `ifelse(`$2', `', `', ``$1$2'')$0(`$1', shift(shift($@)))')') +# joinall(sep, args) - join each ARG, including empty ones, +# into a single string, with each element separated by SEP +define(`joinall', ``$2'_$0(`$1', shift($@))') +define(`_joinall', +`ifelse(`$#', `2', `', ``$1$3'$0(`$1', shift(shift($@)))')') +divert`'dnl |