Sorting algorithms/Gnome sort: Difference between revisions

Content added Content deleted
(→‎{{header|Swift}}: Added a SNOBOL4 implementation.)
m (→‎{{header|R}}: Syntax highlighting.)
Line 2,881: Line 2,881:
=={{header|R}}==
=={{header|R}}==
===Starting from 1===
===Starting from 1===
<lang r>gnomesort <- function(x)
<lang rsplus>gnomesort <- function(x)
{
{
i <- 1
i <- 1
Line 2,912: Line 2,912:


As R is 1-indexed, we need to make some minor adjustments to the given pseudo-code. To give some variety and to remove the previous solution's potentially redundant first run, we have chosen a different adjustment to the previous solution's. We have otherwise aimed to be faithful to the pseudo-code.
As R is 1-indexed, we need to make some minor adjustments to the given pseudo-code. To give some variety and to remove the previous solution's potentially redundant first run, we have chosen a different adjustment to the previous solution's. We have otherwise aimed to be faithful to the pseudo-code.
<lang r>gnomeSort<-function(a)
<lang rsplus>gnomeSort<-function(a)
{
{
i<-2
i<-2