Help us understand the problem. What is going on with this article?

Goでスターリンソート

なぜやろうと思ったか

皆さんご存知のスターリンソートを止まっていたGoとdockerの勉強がてら作成してみます。

ソースコード

package main

import(
  "fmt"
)
func unset(s []int, i int) []int {
  if i >= len(s) {
      return s
  }
  return append(s[:i], s[i+1:]...)
}

func main() {
  stalin := [] int{3, 6, 7, 1, 9, 7, 11, 2}
  fmt.Println(stalin)
  for i := 1; i < len(stalin); i++ {
    fmt.Println("対象:",stalin[i])
    if stalin[i] < stalin[i - 1] {
      stalin = unset(stalin, i)
      fmt.Println("有罪")
    } 
  }
  fmt.Println(stalin)
}

結果

対象: 6
対象: 7
対象: 1
有罪
対象: 7
有罪
対象: 2
有罪
[3 6 7 9 11]

粛清されましたね。
スターリンソートって表現も面白いし、ソートを粛清って言うのも笑っちゃう。

追加
よく見たら全要素見ていないのでまた修正します

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away