Культурный офтопик
 help / color / mirror / Atom feed
From: "Денис Смирнов" <mithraen@altlinux.ru>
To: "культурный офтопик" <smoke-room@lists.altlinux.org>
Subject: Re: [room] Вопрос по Lisp
Date: Tue, 6 Feb 2007 19:28:51 +0300
Message-ID: <20070206162850.GA31516@mw.local.seiros.ru> (raw)
In-Reply-To: <m3odoja6u4.fsf@voins.program.ru>

On Sun, Jan 28, 2007 at 11:33:39AM +0300, Alexey Voinov wrote:

> AV>> Не, ты не понимаешь. :) Тупо - это вот так  (используем srfi-1):
> AV>> (define (trim-zeroes-right data)
> AV>>   (reverse (drop-while zero? (reverse data)))
>> Гм. Логично. В описании к тому же nyquist я почему-то drop-while не нашел
>> :-/
AV> Это из http://srfi.schemers.org/srfi-1/srfi-1.html
AV> В Сommon Lisp наверняка аналогичная функция есть в стандартной
AV> библиотеке. :)

Понял, буду искать. В nyquist (на базе xlisp), где мне это было надо,
ненашел.

>  AV>> (define (trim-zeroes-right data)
>  AV>>   (let loop ((newlen (vector-length data)))
>  AV>>     (let ((index (- newlen 1)))
>  AV>>       (cond ((zero? newlen)
>  AV>>              '#())
>  AV>>             ((zero? (vector-ref data index))
>  AV>>              (loop index))
>  AV>>             (else
>  AV>>              (vector-copy data 0 newlen))))))
>> Только эту конструкцию я не смог прочитать:
> AV>>       (cond ((zero? newlen)
> AV>>              '#())
> AV>>             ((zero? (vector-ref data index))
> AV>>              (loop index))
AV> Если мы в подсчёте нулей дошли до начала вектора (длина нового вектора
AV> равна 0), то возвращаем сразу пустой вектор, не дёргая копирования и
AV> выйдем из цикла.
AV> Если элемент в текущей позиции (index всегда на единицу меньше newlen)
AV> равен 0, то повторить процедуру сначала, уменьшив длину нового вектора
AV> на единицу (т.е. взять вместо длины - индекс). (let <name> ...) -
AV> очень удобная и полезная конструкция в scheme. :) На CL наверняка этот
AV> цикл будет проще записать каким-нибудь другим способом.
AV> Если мы нашли первый не-нуль от конца, то скопируем все нужные
AV> элементы и выйдем из цикла.

А в чем вообще принципиальнальное различие между scheme и lisp? man что на
предмет истории развития этих языков?

-- 
С уважением, Денис

http://freesource.info
----------------------------------------------------------------------------
Небезопасная это штука - wget.
		-- ldv in sisyphus@


  reply	other threads:[~2007-02-06 16:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-26  4:24 Денис Смирнов
2007-01-27 11:28 ` Alexey Voinov
2007-01-28  5:19   ` Денис Смирнов
2007-01-28  8:33     ` Alexey Voinov
2007-02-06 16:28       ` Денис Смирнов [this message]
2007-02-06 17:53         ` Alexey Voinov
2007-02-08 21:50           ` Денис Смирнов
2007-02-14 16:22             ` [room] mpc кракозябры в ID тэгах Денис Смирнов
2007-02-14 14:38               ` Timur Batyrshin
2007-02-19 10:57                 ` Денис Смирнов
2007-02-19 20:25                   ` Aleksey Korotkov
2007-02-20  5:58                     ` Andrew Borodin
2007-02-19 14:29               ` Nick S. Grechukh
2007-02-06 18:20         ` [room] Вопрос по Lisp Maxim Tyurin
2007-02-06 18:34           ` Alexey Voinov
2007-02-07  8:19             ` Maxim Tyurin

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=20070206162850.GA31516@mw.local.seiros.ru \
    --to=mithraen@altlinux.ru \
    --cc=smoke-room@lists.altlinux.org \
    /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

Культурный офтопик

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/smoke-room/0 smoke-room/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 smoke-room smoke-room/ http://lore.altlinux.org/smoke-room \
		smoke-room@lists.altlinux.org smoke-room@lists.altlinux.ru smoke-room@lists.altlinux.com smoke-room@altlinux.ru smoke-room@altlinux.org smoke-room@altlinux.com
	public-inbox-index smoke-room

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.smoke-room


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git