15,615,016 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View Javascript questions
View C++ questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Robert g Blair (Top 6 by date)
Robert g Blair
1-Dec-16 23:02pm
View
You can test this code here: https://www.tutorialspoint.com/compile_cobol_online.php
Robert g Blair
1-Dec-16 22:04pm
View
David - its very hard to compare.
If you remove the Display statement it will run in less than a millisecond on, say, a Fujitsu mainframe.
It runs in a couple milliseconds on a Ubuntu box with GnuCobol.
But what I coded was very compiler friendly - hard coded literals, single statement etc.
FYI: When I say "intrinsic" I mean in this sense: https://en.wikipedia.org/wiki/Intrinsic_function
Ie, the compiler is optimizing the string handling involved in the INSPECT statement execution. Whether it does it well or no is a function of the compiler's competence.
Robert g Blair
1-Dec-16 19:42pm
View
Chris:
I believe it is appropriate to give an award for "Least Lines of Code".
A very objective metric, and serves the higher purpose of combating code-bloat.
Robert g Blair
1-Dec-16 19:33pm
View
Well, you could do a lot to make it more gooderer:
- The string literals can be variables, which you could get from an input source, eg, a database, an input form, xml, whatever.
- You can also use TALLYING and BEFORE INITIAL ...
But case - case in COBOL is not so easy.
Sorry, but for COBOL solutions you have to choose a case. Upper or lower.
Case is merely a social construct y'know :)
Robert g Blair
1-Dec-16 15:59pm
View
David - my COBOL solution took just 15 minutes to write (and I haven't coded COBOL for many years).
And it will run blindingly fast. Everything is handled in a single intrinsic, compiler optimized, command.
I didn't add the "extra" bits you have, because they weren't in the spec, and I didn't want to spend any time on it.
To implement "pooppoop" -> "p**pp**p" is a simple REPLACING operation.
To implement "poopoopoop" -> "p**p**p**p" would involve a REPLACING "poo" BEFORE INITIAL "p**" - and recursing.
Robert g Blair
30-Nov-16 22:33pm
View
I enjoyed that. I haven't coded in COBOL for 30 years.
I will do the next one in UCSD Pascal, or RPG III, or maybe FORTRAN IV.
(depending on the problem).
Show More