🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.funkcyjne
Article #468

Re: czemu tu taka cisza?

#468
From: Tomasz Baranski
Date: Fri, 10 Oct 2003 14:02
53 lines
2365 bytes
In article <3045-1065776488@gw.magellan.net.pl>, Przemek Wisniewski wrote:
>> Andrzej Wasowski <wasowski@see.my.sig> writes:
>> 
>>>>- "gdzie sie podziala petla for?"... :)
>>>
>>>a po co to komu? 
>> 
>> do odrozniania teoretykow od praktykow programowania :>
> 
> W haskellu chyba nie ma 'for', nie znam go dobrze, cos tam podlubalem, 
> ale 'for' nie byl nigdy potrzebny.
> 
> Po drugie sa dwa rodzaje 'for':
> 
> paskudny: for (i=0; i<10; ++i) / for i = 0 to 9
> ciekawszy: for x in [3,4,5,6,7]
> 
> Wiec jesli juz jakis 'for' jest uzyteczny to tylko pythoniasty.

Hmm...

Common Lisp:
(dotimes (i 10) ...)
(dolist (x '(3 4 5 6 7)) ... )

; nasty little ones:
(do ((i 0 (+ i 1)))
    ((>= i 10))
  ...)
(do ((x '(3 4 5 6 7) (cdr x)))
    ((null x))
  ...)

I oczywiscie jest jeszcze makro loop, ktorej tajnikow nie zglebilem. Proste
for (zwracajacego nieparzyste wartosci) mozna zrobic tak:

(loop for n from 1 to 10
       when (oddp n)
         collect n)



ISLisp:
(for (i 0 (+ i 1)) (< i 10) ...)
(for (x '(3 4 5 6 7) (cdr x)) ((null x)) ...)

Za wersje ISlispa nie recze, nie mam pod reka zadnej implementacji, zeby
sprawdzic.

-- 
Tomasz Baranski		yubi_newsy (at) go2 (dot) pl
The best way to predict the future is to invent it.
                Alan Kay, Palo Alto Research Center
Technical Details
Message-ID: <slrnbodeup.1ng.adres@sgnpokr62083101.Global.ad.sabre.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!not-for-mail
References: <Xns940C7E860B845dupajasio@127.0.0.1> <87he2m8vkq.fsf@hector.domek> <Xns940C891076596dupajasio@127.0.0.1> <s99y8vytfl4.fsf@localhost.localdomain> <Xns940CD6EFCBADzdomu@127.0.0.1> <s99y8vxt6i7.fsf@localhost.localdomain> <87d6d8kisy.fsf@hector.domek> <3045-1065776488@gw.magellan.net.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!not-for-mail
From: Tomasz Baranski <adres@w.stopce>
Newsgroups: pl.comp.lang.funkcyjne
Subject: Re: czemu tu taka cisza?
Date: Fri, 10 Oct 2003 16:02:04 +0200
Organization: University of Mining & Metallurgy
Lines: 54
Message-ID: <slrnbodeup.1ng.adres@sgnpokr62083101.Global.ad.sabre.com>
References: <Xns940C7E860B845dupajasio@127.0.0.1> <87he2m8vkq.fsf@hector.domek> <Xns940C891076596dupajasio@127.0.0.1> <s99y8vytfl4.fsf@localhost.localdomain> <Xns940CD6EFCBADzdomu@127.0.0.1> <s99y8vxt6i7.fsf@localhost.localdomain> <87d6d8kisy.fsf@hector.domek> <3045-1065776488@gw.magellan.net.pl>
NNTP-Posting-Host: media.miks.uj.edu.pl
X-Trace: galaxy.uci.agh.edu.pl 1065794524 6166 149.156.91.2 (10 Oct 2003 14:02:04 GMT)
X-Complaints-To: usenet@uci.agh.edu.pl
NNTP-Posting-Date: Fri, 10 Oct 2003 14:02:04 +0000 (UTC)
User-Agent: slrn/0.9.7.4 (Win32)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit