Wanted to check out the speed loss in my version due to 2 external function calls.
(and notwithstanding coding time reduction by using library functions)
Also took the opportunity to correct null string problem noted by Marc'Antonio
(defun MidVerseV2
-kirby
(MyString
/ OutVal L FirstChar LastChar CNT
) ; [challenge] A31 : Midverse - Reverse the middle letters of a word. Version 2
; Input:
; MyString - (string) string to be modified
; Returns:
; modfied string
; Uses custom functions:
; none!
(setq CNT
(1- CNT
)) ; work backwards ) ; close repeat
)
) ; close if
)
) ; close if
OutVal
)
Re-running RJP's benchmark analysis:
Elapsed milliseconds / relative speed for 8192 iteration(s):
(MIDVERSE-RJP "retinues").........1531 / 3.45 <fastest>
(MIDVERSE-GILE "retinues")........1610 / 3.28
(MIDVERSE_A2 "retinues")..........1875 / 2.82
(MIDVERSE-KIRBYV2 "retinues").....1922 / 2.75
(MIDVERSE_A4 "retinues")..........1953 / 2.70
(MIDVERSE_A "retinues")...........2157 / 2.45
(MIDVERSE-KIRBY "retinues").......2266 / 2.33
(MIDVERSE-RJP2 "retinues")........3110 / 1.70
(MIDVERSE-7 "retinues")...........4922 / 1.07
(MIDVERSE-GILE2 "retinues").......5281 / 1.00 <slowest>
So in my case about a 15% speed increase from eliminating the function calls, but results vary a bit each time you run the Benchmark.
And noting that I many not be using the latest version of MP's benchmark function, found here:
http://www.theswamp.org/index.php?topic=3952.0