🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #10209

Re: szkolka

#10209
From: Krzyszt_off
Date: Thu, 16 Jan 2003 15:03
21 lines
1434 bytes
> PS2. jak ktos chce, moze tez zrobic w druga strone - z rzymskich na
arabskie

function Arab(rome){
  function Digit(a){
    return
a=='I'?1:a=='V'?5:a=='X'?10:a=='L'?50:a=='C'?100:a=='D'?500:a=='M'?1000:0
  }
  var sum=0
  for(var i=0;i<rome.length;i++)

sum-=Digit(rome.charAt(i))*((Digit(rome.charAt(i))<Digit(rome.charAt(i+1)))*
2-1)
  return sum
}

Nie mam teraz czasu na pierwsza czesc ;-(

Krzysiek

P.S.: jak Ci sie podoba moj boolean * 2 - 1 ? - pozbylem sie if-else ;)
Technical Details
Message-ID: <b06hbj$jbk$1@news.tpi.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed.silweb.pl!news.us.edu.pl!news.nask.pl!news.atman.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
References: <b06bao$cp7$1@news.tpi.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed.silweb.pl!news.us.edu.pl!news.nask.pl!news.atman.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
From: "Krzyszt_off" <leszek.miller@grube.ryby.pl>
Newsgroups: pl.comp.lang.javascript
Subject: Re: szkolka
Date: Thu, 16 Jan 2003 16:03:54 +0100
Organization: tp.internet - http://www.tpi.pl/
Lines: 23
Message-ID: <b06hbj$jbk$1@news.tpi.pl>
References: <b06bao$cp7$1@news.tpi.pl>
NNTP-Posting-Host: kalmar.mila.edu.pl
X-Trace: news.tpi.pl 1042729139 19828 195.116.40.8 (16 Jan 2003 14:58:59 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: Thu, 16 Jan 2003 14:58:59 +0000 (UTC)
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit