From: Ilya Palagin <tux@fioc.kz>
To: community@altlinux.ru
Subject: Re: [Comm] Сортировка строк и старт программ
Date: Sun, 10 Nov 2002 01:45:00 +0600
Message-ID: <3DCD65BC.9090001@fioc.kz> (raw)
In-Reply-To: <200211091834.54216.community@netaddres.ru>
Konstantin wrote:
> И еще раз добрый вечер :)
>
> 1) Как "отсортировать" строки в файле случайным образом? man что?
в целях популяризации ruby - вот-с :-)
-----------------------
#!/usr/bin/ruby -w
content = Hash.new
File.open(ARGV[0], "r") do |f|
cnt = 0
while (line = f.gets) # Заполняем хэш content строками из файла
content[cnt] = line; cnt += 1
end
content.keys.each do |n|
content[n], content[rand(cnt)] = content[rand(cnt)], content[n] #
Переставляем элементы
end
end
content.keys.each { |n| print content[n]}
-----------------------
next prev parent reply other threads:[~2002-11-09 19:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-09 16:37 Konstantin
2002-11-09 16:39 ` Leonid B. Sysoletin
2002-11-09 19:36 ` Konstantin
2002-11-10 4:18 ` Smirnov Alexey
2002-11-10 13:23 ` Konstantin
2002-11-10 8:17 ` Pyatnitskich Evgeniy
2002-11-10 13:23 ` Konstantin
2002-11-09 17:07 ` Alexey Tourbin
2002-11-09 19:37 ` Konstantin
2002-11-09 19:49 ` [Comm] Re[2]: " ASA
2002-11-10 13:23 ` Konstantin
2002-11-09 20:09 ` Sergey V. Degtyaryov
2002-11-09 19:45 ` Ilya Palagin [this message]
2002-11-09 19:57 ` Ilya Palagin
2002-11-09 20:15 ` [Comm] Re[2]: " ASA
2002-11-09 20:30 ` Ilya Palagin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DCD65BC.9090001@fioc.kz \
--to=tux@fioc.kz \
--cc=community@altlinux.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux Community general discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
public-inbox-index community
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.community
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git