🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Przyjemny, elegancki, prosty jezyk funkcyjny

#906
From: Marcin 'Qrczak' Kowalczyk
Date: Fri, 18 May 2007 22:57
47 lines
2231 bytes
Dnia 18-05-2007, pią o godzinie 23:33 +0200, Michał Przybyłek
napisał(a):

> (defun fact (n)
>    (loop with acc = 1
>          for i from 1 to n
>            do (setq acc (* acc i))
>      finally (return acc) ) )
> 
> 
> (defun zip-2 (list-1 list-2)
>    (loop for e1 in list-1
>          for e2 in list-2
>            collect (cons e1 e2) ) )
> 
> 
> (defun inject-position (list)
>    (loop for e in list
>          for n from 0
>            collect (cons e n) ) )
> 
> 
> Pokaż mi jak to zapiszesz w C++/Javie, to zobaczymy, czy jest zwięźlej 
> lub wygodniej :-P

Nie będę bronił C++ ani Javy. W każdym razie w moim Kogucie wygląda to
tak:

def Fact n {
   Between 1 n->Fold 1 '*'
};

// Zip już jest standardowo. Gdyby nie było:
def Zip seq1 seq2 {
   Map seq1 seq2 ','
};

def InjectPosition seq {
   Zip seq (From 0)
};

więc składnia Common Lispa pod tym względem nie robi na mnie wrażenia.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/
Technical Details
Message-ID: <1179529031.15951.32.camel@qrnik>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.internetia.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
References: <1179163778.661628.303210@h2g2000hsg.googlegroups.com> <f2ak3b$rpj$1@nemesis.news.tpi.pl> <1179268422.157417.102270@o5g2000hsb.googlegroups.com> <f2ej9b$f4k$1@nemesis.news.tpi.pl> <1179440350.449394.188960@q23g2000hsg.googlegroups.com> <f2l623$or0$1@atlantis.news.tpi.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.internetia.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
From: Marcin 'Qrczak' Kowalczyk <qrczak@knm.org.pl>
Newsgroups: pl.comp.lang.funkcyjne
Subject: Re: Przyjemny, elegancki, prosty jezyk funkcyjny
Date: Sat, 19 May 2007 00:57:11 +0200
Organization: tp.internet - http://www.tpi.pl/
Lines: 52
Message-ID: <1179529031.15951.32.camel@qrnik>
References: <1179163778.661628.303210@h2g2000hsg.googlegroups.com>  <f2ak3b$rpj$1@nemesis.news.tpi.pl>  <1179268422.157417.102270@o5g2000hsb.googlegroups.com>  <f2ej9b$f4k$1@nemesis.news.tpi.pl>  <1179440350.449394.188960@q23g2000hsg.googlegroups.com>  <f2l623$or0$1@atlantis.news.tpi.pl>
NNTP-Posting-Host: paf87.warszawa.sdi.tpnet.pl
Mime-Version: 1.0
X-Trace: nemesis.news.tpi.pl 1179529307 12341 217.96.225.87 (18 May 2007 23:01:47 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: Fri, 18 May 2007 23:01:47 +0000 (UTC)
In-Reply-To: <f2l623$or0$1@atlantis.news.tpi.pl>
X-Mailer: Evolution 2.10.0 PLD Linux
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit