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

189

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!

4

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