List indexing in codeworld-base library

12 views
Skip to first unread message

Chris Smith

unread,
Jul 6, 2017, 2:32:06 PM7/6/17
to codeworl...@googlegroups.com
I know this isn't sufficient notice, but just a heads-up that there was a breaking change in list indexing last night, for anyone using codeworld-base.  (That means users of http://code.world, but NOT users of http://code.world/haskell)

The list indexing functions and operators - at and # - are now 1-based instead of 0-based.  The same is true of player numbers in collaborationOf.  Programs that use these will generate a compile warning, to notify you about the change.  I'll leave the warning there until the fall school term.

Sorry for the sudden change.  It was important to get this in quickly, and there was really no good way to maintain backward compatibility.

Gergely Mészáros

unread,
Jul 7, 2017, 6:25:28 AM7/7/17
to codeworld-discuss

Personally I think it's a very welcome change.

In C the expression v[n] means "I want to increase pointer v by n*sizeof(somestruct) before resolving"
therefore 0 based indexing is simple and natural.

In Haskell Lists (or codeword's) no such interpretation exists except that I want the Nth element,
0 based indexing is confusing, while N+ feels err... More Natural. :)

cheers,
Gergely
Reply all
Reply to author
Forward
0 new messages