Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 new exercise: pig-latin #142

Merged
merged 6 commits into from
May 2, 2024
Merged

1 new exercise: pig-latin #142

merged 6 commits into from
May 2, 2024

Conversation

kapitaali
Copy link
Contributor

Hi,

please find 1 new exercise to the COBOL track: pig-latin

@kapitaali
Copy link
Contributor Author

whoops, there was a comma missing in config.json

fixed now

Copy link
Member

@axtens axtens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

       01 STARTING-POINT           USAGE BINARY-LONG.       
       01 ITEM-COUNT               USAGE BINARY-LONG.       
           INITIALIZE ITEM-COUNT.
           INSPECT WS-INPUT TALLYING ITEM-COUNT FOR ALL SPACE.
           UNSTRING WS-INPUT DELIMITED BY ' ' 
                INTO WORDSLIST(ITEM-COUNT)
                WITH POINTER STARTING-POINT.

That does however appear to break one of the tests. It's not vital. In one sense the code just has to work, no matter how inefficiently. At another level, you learning to write better COBOL isn't a bad thing.

@kapitaali
Copy link
Contributor Author

       01 STARTING-POINT           USAGE BINARY-LONG.       
       01 ITEM-COUNT               USAGE BINARY-LONG.       
           INITIALIZE ITEM-COUNT.
           INSPECT WS-INPUT TALLYING ITEM-COUNT FOR ALL SPACE.
           UNSTRING WS-INPUT DELIMITED BY ' ' 
                INTO WORDSLIST(ITEM-COUNT)
                WITH POINTER STARTING-POINT.

The code as it is given here leaves the WORDSLIST table empty. So it would need to be changed somehow.

In fact I tried looking up some kind of (working example) code from somewhere so that I would not have to write any indices. But I could not find any. I've seen examples with PERFORM UNTIL SOMECHAR = 'Y' and then the UNSTRING contains NOT ON OVERFLOW MOVE 'Y' TO SOMECHAR, but that gives me equally empty table.

For example here they do just like I did: https://users.cs.jmu.edu/adamses/Web/CS%20430%20Fall%202004/Student%20Project%20Work/Akanni%20-%20COBOL/COBOL%20Tutorial%20HTML-Pages/The%20UNSTRING%20verb.htm

That does however appear to break one of the tests. It's not vital. In one sense the code just has to work, no matter how inefficiently. At another level, you learning to write better COBOL isn't a bad thing.

Aye I don't mind learning, but I do need some sort of source material.

@axtens
Copy link
Member

axtens commented May 1, 2024

My apologies. I thought that was working. Hmmm ... shall get back to you.

@axtens
Copy link
Member

axtens commented May 2, 2024

See my exploration on onecompiler. I thought COBOL would unstring into the array but, alas, I have to be more explicit about my intention.

@kapitaali
Copy link
Contributor Author

I changed it to UNSTRING WITH POINTER, it's good to know those types of tricks if you have a long string and a resulting table of millions of entries.

@axtens axtens self-requested a review May 2, 2024 13:17
@axtens axtens merged commit 876cca8 into exercism:main May 2, 2024
3 checks passed
@kapitaali kapitaali deleted the pig-latin branch May 2, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants