Article View: es.comp.os.linux.programacion
Article #7988Re: Leer un fichero
From: Eduardo Muñoz
Date: Fri, 03 Jan 2003 00:07
Date: Fri, 03 Jan 2003 00:07
27 lines
1679 bytes
1679 bytes
ionidk@terra.es (DK) writes:
> Feliz a�o:
>
> Quiero sacar la media de una serie de datos que tengo almacenados en
> un fichero. El fichero podria ser de la siguiente manera:(datos.txt)
Parece que cada uno est� dando una respuesta en un lenguaje
distinto...
Aqu� est� mi propuesta en Common Lisp:
(defun foo ()
(with-open-file (in "foo.txt")
(loop as line = (read-line in nil nil)
while line do
sum (read-from-string line) into total
count 1 into numeros
finally (return (float (/ total numeros))))))
(foo) => 32.363636
--
Eduardo Mu�oz
Technical Details
Message-ID:
<uof6zm6yi.fsf@jet.es>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor-online.net!fu-berlin.de!uni-berlin.de!213-97-131-125.uc.nombres.ttd.ES!not-for-mailReferences:
<7d4ff0e4.0301020707.6388a1a6@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,5cf283a7acb0d167 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2003-01-02 16:12:07 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor-online.net!fu-berlin.de!uni-berlin.de!213-97-131-125.uc.nombres.ttd.ES!not-for-mail From: "Eduardo Muñoz" <emf@jet.es> Newsgroups: es.comp.os.linux.programacion Subject: Re: Leer un fichero Date: 03 Jan 2003 01:07:33 +0100 Organization: Not likely Lines: 27 Sender: emf@EMF Message-ID: <uof6zm6yi.fsf@jet.es> References: <7d4ff0e4.0301020707.6388a1a6@posting.google.com> NNTP-Posting-Host: 213-97-131-125.uc.nombres.ttd.es (213.97.131.125) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 1041552726 12044539 213.97.131.125 (16 [67897]) X-Orig-Path: 172.26.0.7!nobody User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2