How to resolve the algorithm Comma quibbling step by step in the Lang programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Comma quibbling step by step in the Lang programming language
Table of Contents
Problem Statement
Comma quibbling is a task originally set by Eric Lippert in his blog.
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
Test your function with the following series of inputs showing your output here on this page:
Note: Assume words are non-empty strings of uppercase characters for this task.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Comma quibbling step by step in the Lang programming language
Source code in the lang programming language
fp.quibble = (&words) -> {
$len $= @&words
$output = \{\e
$i
repeat($[i], $len) {
$output += &words[$i] ||| ($i == -|$len?\e:($i == $len - 2?\sand\s:\,\s))
}
$output += \}\e
return $output
}
fn.println(fp.quibble(fn.arrayOf()))
fn.println(fp.quibble(fn.arrayOf(ABC)))
fn.println(fp.quibble(fn.arrayOf(ABC, DEF)))
fn.println(fp.quibble(fn.arrayOf(ABC, DEF, G, H)))
You may also check:How to resolve the algorithm Literals/String step by step in the Fortran programming language
You may also check:How to resolve the algorithm Program termination step by step in the Joy programming language
You may also check:How to resolve the algorithm Sum multiples of 3 and 5 step by step in the Forth programming language
You may also check:How to resolve the algorithm Hostname step by step in the Tcl programming language
You may also check:How to resolve the algorithm Floyd-Warshall algorithm step by step in the D programming language