[Bradford] MY mystery puzzle for this evening

Darren Drapkin darren.drapkin at ntlworld.com
Tue Apr 9 17:44:35 UTC 2024


/+This is a genuine post from the Dlang forums. I am treating it as a kata.
Write a function "join" that uses ~ to append to its first argument, all the 
subsiquent arguments. Check that the first argument is an l-value an that the 
others are strings or characters.
If you want a permalink its
<https://forum.dlang.org/post/gdhqemwuyasthgjvjpkr@forum.dlang.org>

Post follows...
  
I'm looking for more readable standard function to add a character literal to 
a string.

The ~ operator is clearly not great while reading a source code.
I'm not here to discuss that. I'm looking for a function inside standard 
library.

The function should be straightforward, up to two words.

Here is what I expect from a programming language:

Pseudo example:

import std;
void main(){
	string word = hello;
	join(word, 'f', " ", "World");
	writeln(word);   	// output: hellof World
	
}
+/

//my answer follows in the meeting, and a comment on it
// extra marks for getting the comment right too

-- 
Yours &c.
Darren Drapkin





More information about the Bradford mailing list