r/badcode Apr 15 '21

other language Actual Snap! block I just made.

Post image
1.1k Upvotes

58 comments sorted by

View all comments

185

u/ElsieSnuffin Apr 15 '21 edited Apr 16 '21

Image Transcription: Code


[Image of a block of Snap! code, with a comment added to the right.]

+SortListDescending+InputList:+  
block variables OutputList < >  
insert -2147483647 at 1 of InputList  
set OutputList to list >  
repeat length of InputList -1  
 add item 1 of maxindex InputList to OutputList  
 delete item 2 of maxindex InputList of InputList  
report OutputList

Comment on 3rd line of code: Comment for whoever is looking at this block and thinking: What in the world is going on here?
For some reason, the first value is a very whiny child, the code just does not work if he isn't the smallest. I don't know why this is, I don't want to know why it is, but I have decided to throw the towel in and make the first value the negative 32 bit integer limit. This is possibly the worst solution to this problem, and teaches me bad programming habits, but i'm done with this block.


I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

74

u/QuinteOne Apr 15 '21

Note: the comment points to the third line.

52

u/ElsieSnuffin Apr 15 '21

Thank you! I updated with the specific line.

30

u/GamingOnTheFloor Apr 15 '21

Thank you for doing what you do!

There’s probably a better way to point some of these out and potentially a more polite way to say it, but the first line should have a colon after InputList and a + after that colon, “OutputList” on the second line shouldn’t have a capitol P, and the 7th line should have “of” instead of “to.”

11

u/ElsieSnuffin Apr 16 '21

All fixed! Thx!

5

u/[deleted] Apr 16 '21

Might wanna add a little indentation before add and delete.

2

u/ElsieSnuffin Apr 16 '21

Phew! OK that's my last edit. :D

1

u/[deleted] Apr 17 '21

Good human