mob/Login()
var list/old_list = list(1,2,3,4,5,6,7,8,9)
var list/new_list = [number for number in old_list if number % 2 == 0]
ID:2958912
![]() Jan 1, 3:34 pm
|
|||||||
| |||||||
The ability to "inline" the for() procedure.
|
I don't know what a good syntax to match dm would be, but it would be a nice feature imo since we can't define procedures for /list.
I wouldn't say it's jank just advanced comprehension. |
I can see how this is an ask but I don't think it's a good value trade. Pythonisms tend to be a bit of a flow break for me, although perhaps that's just because I don't do a lot of work in python. I think I can happily accuse python list comprehension of being clever first, maintainable second.
var/list/old_list = list(1, 2, 3, 4, 5, 6, 7, 8, 9) As a possibly syntax, [A[ as B] in C[ if D]]. I don't believe I'm being unrealistic in decoupling the hint of A from B, or in making B and D optional. var/list/mob_friends = [friend as /mob in faction.friends] Sure! Cute. Or if we make it slightly realistic ... var/list/jelly_friends = [mob/playable/opossum/friend as /mob/playable/opossum in faction.friends if friend.IsActivePlayer() && friend.NotPlayingDead() && friend.MeetsJellyNeeds()] If we want to do more than trivial numerics, line ends start heading right fast. To me that's just an even less comprehensible pyramid of doom. -1 |
For this use-case, it would be nice to see something like JavaScript's map()/reduce()/filter() implemented for the /list prototype.
|
Yeah, I could see that.
var/list/outlist = list_map(inlist, /proc/some_transformer) /proc/some_transformer(entry, index) return ... |
-1