How to resolve the algorithm Comma quibbling step by step in the Miranda programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Comma quibbling step by step in the Miranda 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 Miranda programming language
Source code in the miranda programming language
main :: [sys_message]
main = [Stdout (show test ++ ": {" ++ quibble test ++ "}\n") | test <- tests]
tests :: [[[char]]]
tests = [ [],
["ABC"],
["ABC","DEF"],
["ABC","DEF","G","H"] ]
quibble :: [[char]]->[char]
quibble [] = []
quibble [word] = word
quibble [word1,word2] = word1 ++ " and " ++ word2
quibble (word:words) = word ++ ", " ++ quibble words
You may also check:How to resolve the algorithm Matrix transposition step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Abstract type step by step in the C# programming language
You may also check:How to resolve the algorithm Circular primes step by step in the Scala programming language
You may also check:How to resolve the algorithm Langton's ant step by step in the Swift programming language
You may also check:How to resolve the algorithm Shell one-liner step by step in the FutureBasic programming language