{"action":"created","issue":{"url":"https://api.github.com/repos/rebol/rebol-issues/issues/1983","repository_url":"https://api.github.com/repos/rebol/rebol-issues","labels_url":"https://api.github.com/repos/rebol/rebol-issues/issues/1983/labels{/name}","comments_url":"https://api.github.com/repos/rebol/rebol-issues/issues/1983/comments","events_url":"https://api.github.com/repos/rebol/rebol-issues/issues/1983/events","html_url":"https://github.com/rebol/rebol-issues/issues/1983","id":126185177,"number":1983,"title":"Ordinal functions in the other direction","user":{"login":"rebolbot","id":13850819,"avatar_url":"https://avatars.githubusercontent.com/u/13850819?v=3","gravatar_id":"","url":"https://api.github.com/users/rebolbot","html_url":"https://github.com/rebolbot","followers_url":"https://api.github.com/users/rebolbot/followers","following_url":"https://api.github.com/users/rebolbot/following{/other_user}","gists_url":"https://api.github.com/users/rebolbot/gists{/gist_id}","starred_url":"https://api.github.com/users/rebolbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rebolbot/subscriptions","organizations_url":"https://api.github.com/users/rebolbot/orgs","repos_url":"https://api.github.com/users/rebolbot/repos","events_url":"https://api.github.com/users/rebolbot/events{/privacy}","received_events_url":"https://api.github.com/users/rebolbot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rebol/rebol-issues/labels/Type.wish","name":"Type.wish","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2013-03-04T20:43:45Z","updated_at":"2016-02-21T21:57:04Z","closed_at":null,"body":"_Submitted by:_ **BrianH**\n\nIn the ongoing debate about 1-based vs. 0-based and contiguous vs. 0-hole indexing, Meredith McGhan (@mmcghan on StackOverflow) suggested the possibility of having negative ordinal functions to correspond to our existing positive ordinal functions (for the moment let's ignore what \"ordinal\" means elsewhere and use it in its Rebol jargon meaning here). A -FIRST function would return the value from the first back from the current position of the series, and so on for -SECOND and such.\n\nHowever, it turns out that -FIRST is difficult to distinguish from FIRST when reading code, so those names really aren't going to work. Instead of thinking of the ordinal functions as going in a positive direction, let's instead think of them as going forward. That would make the ordinals in the other direction going backward, with names like FIRST-BACK, SECOND-BACK, through TENTH-BACK, much easier to distinguish from their forward counterparts.\n\nThese functions would refer backwards according to the model that SKIP uses for negative numbers, regardless of how PICK would treat those same numbers. They would be wrappers around PICK, and have the same out-of-bounds behavior as PICK. They could be mezzanine or native - they're tiny and easy to write either way - but we would benefit from having them be native in R3. We would also benefit from having them be ported to R2 and Red, as wrappers around their respective PICK actions, as long as the external behavior is identical across all platforms. This will make portable code much easier to write.\n\n```rebol\n; Logically, assuming an index space without bounds constraining, they mean roughly this:\nfirst-back: func [\"Returns the first value back in a series.\" value] [first skip :value -1]\nsecond-back: func [\"Returns the second value back in a series.\" value] [first skip :value -2]\nthird-back: func [\"Returns the third value back in a series.\" value] [first skip :value -3]\nfourth-back: func [\"Returns the fourth value back in a series.\" value] [first skip :value -4]\nfifth-back: func [\"Returns the fifth value back in a series.\" value] [first skip :value -5]\nsixth-back: func [\"Returns the sixth value back in a series.\" value] [first skip :value -6]\nseventh-back: func [\"Returns the seventh value back in a series.\" value] [first skip :value -7]\neighth-back: func [\"Returns the eighth value back in a series.\" value] [first skip :value -8]\nninth-back: func [\"Returns the ninth value back in a series.\" value] [first skip :value -9]\ntenth-back: func [\"Returns the tenth value back in a series.\" value] [first skip :value -10]\n\n; In R2 and Red\nfirst-back: func [\"Returns the first value back in a series.\" value] [pick :value -1]\nsecond-back: func [\"Returns the second value back in a series.\" value] [pick :value -2]\nthird-back: func [\"Returns the third value back in a series.\" value] [pick :value -3]\nfourth-back: func [\"Returns the fourth value back in a series.\" value] [pick :value -4]\nfifth-back: func [\"Returns the fifth value back in a series.\" value] [pick :value -5]\nsixth-back: func [\"Returns the sixth value back in a series.\" value] [pick :value -6]\nseventh-back: func [\"Returns the seventh value back in a series.\" value] [pick :value -7]\neighth-back: func [\"Returns the eighth value back in a series.\" value] [pick :value -8]\nninth-back: func [\"Returns the ninth value back in a series.\" value] [pick :value -9]\ntenth-back: func [\"Returns the tenth value back in a series.\" value] [pick :value -10]\n```\n\n<sup>**CC - Data** [ Version: r3 master Type: Wish Platform: All Category: Native Reproduce: Always Fixed-in:none ]</sup>"},"comment":{"url":"https://api.github.com/repos/rebol/rebol-issues/issues/comments/186926574","html_url":"https://github.com/rebol/rebol-issues/issues/1983#issuecomment-186926574","issue_url":"https://api.github.com/repos/rebol/rebol-issues/issues/1983","id":186926574,"user":{"login":"ladislav","id":460068,"avatar_url":"https://avatars.githubusercontent.com/u/460068?v=3","gravatar_id":"","url":"https://api.github.com/users/ladislav","html_url":"https://github.com/ladislav","followers_url":"https://api.github.com/users/ladislav/followers","following_url":"https://api.github.com/users/ladislav/following{/other_user}","gists_url":"https://api.github.com/users/ladislav/gists{/gist_id}","starred_url":"https://api.github.com/users/ladislav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ladislav/subscriptions","organizations_url":"https://api.github.com/users/ladislav/orgs","repos_url":"https://api.github.com/users/ladislav/repos","events_url":"https://api.github.com/users/ladislav/events{/privacy}","received_events_url":"https://api.github.com/users/ladislav/received_events","type":"User","site_admin":false},"created_at":"2016-02-21T21:57:04Z","updated_at":"2016-02-21T21:57:04Z","body":"BrianH: \"...referring to a discussion of a different number system (only positive or positive/negative with no 0) \" - perhaps surprisingly for you, such a number system does not exist at all"}}