How to resolve the algorithm Phrase reversals step by step in the Common Lisp programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Phrase reversals step by step in the Common Lisp programming language
Table of Contents
Problem Statement
Given a string of space separated words containing the following phrase:
Show your output here.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Phrase reversals step by step in the Common Lisp programming language
Source code in the common programming language
(defun split-string (str)
"Split a string into space separated words including spaces"
(do* ((lst nil)
(i (position-if #'alphanumericp str) (position-if #'alphanumericp str :start j))
(j (when i (position #\Space str :start i)) (when i (position #\Space str :start i))) )
((null j) (nreverse (push (subseq str i nil) lst)))
(push (subseq str i j) lst)
(push " " lst) ))
(defun task (str)
(print (reverse str))
(let ((lst (split-string str)))
(print (apply #'concatenate 'string (mapcar #'reverse lst)))
(print (apply #'concatenate 'string (reverse lst))) )
nil )
You may also check:How to resolve the algorithm Named parameters step by step in the Nim programming language
You may also check:How to resolve the algorithm 15 puzzle game step by step in the Arturo programming language
You may also check:How to resolve the algorithm Ackermann function step by step in the Pure programming language
You may also check:How to resolve the algorithm Phrase reversals step by step in the REXX programming language
You may also check:How to resolve the algorithm One-dimensional cellular automata step by step in the Retro programming language