From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: bolega Newsgroups: gmane.emacs.help Subject: Random number generation in LISP or using it Date: Wed, 10 Jun 2009 08:21:39 -0700 (PDT) Organization: http://groups.google.com Message-ID: <0c194ee2-6347-4a46-8932-37d144e9265a@z7g2000vbh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1244708456 28929 80.91.229.12 (11 Jun 2009 08:20:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Jun 2009 08:20:56 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 11 10:20:54 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MEfWm-00044f-Dc for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Jun 2009 10:20:52 +0200 Original-Received: from localhost ([127.0.0.1]:45419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MEfWl-0001X4-PM for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Jun 2009 04:20:51 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!postnews.google.com!z7g2000vbh.googlegroups.com!not-for-mail Original-Newsgroups: comp.lang.lisp,comp.lang.scheme,gnu.emacs.help Original-Lines: 38 Original-NNTP-Posting-Host: 75.28.131.245 Original-X-Trace: posting.google.com 1244647300 2985 127.0.0.1 (10 Jun 2009 15:21:40 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 10 Jun 2009 15:21:40 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z7g2000vbh.googlegroups.com; posting-host=75.28.131.245; posting-account=REkl4woAAABFXaU7nL79XtGpnmNCQ415 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30),gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu comp.lang.lisp:268955 comp.lang.scheme:81381 gnu.emacs.help:169898 X-Mailman-Approved-At: Thu, 11 Jun 2009 04:20:11 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:65139 Archived-At: I am a newbie with the following problem. A the outset let me state that the limitation is that I have to use this inside emacs to scramble a set of chosen lines like you do "reverse-region" or "sort-lines". It is possible that I can call some scheme or clisp functions. What is a fast(est) method to randomize lines based on the capabilities of emacs ? The function "random" does not work in emacs. I guess one get the start line and end line of a marked region and then use that to disorder (or re-order) the lines according to a list of random numbers generated ? 1 -> 5 2 -> 8 3 -> 6 4 -> 9 5 -> 1 6 -> 3 7 -> 2 8 -> 7 9 -> 4 and then use these pairs to reorder the lines. I guess there is a need for one or two variables to hold the lines, or just a kill or the top line and go down a certain number of random steps and paste it there ? Then come back to the top and do the same thing. The type of capacity I am looking is to randomize about few hundred short lines of about 20 to 30 characters. In this case one needs to generate a random number that is an integer and lies between the lines start and end of region. It can be done by some modulo type operation if available in emacs lisp. Thanks for any help. gnuist