🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: szkolka

#10210
From: Vax
Date: Thu, 16 Jan 2003 19:07
29 lines
1883 bytes
Użytkownik "Krzyszt_off" <leszek.miller@grube.ryby.pl> napisał w wiadomości
news:b06hbj$jbk$1@news.tpi.pl...
[...]

skupmy sie narazie na tym kawaleczku:

>   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}

a ja sobie "z palucha" napisze pare innych "Digitow" :)

function
Digit(a,d,s){for(a='IVXLCDM'.indexOf(a),s=1,d=2;a--;s*=d=7-d);return s}
function Digit(a,s){for(a='IVXLCDM'.indexOf(a),s=1;a--;s*=a&1?2:5);return s}
function Digit(a){a='IVXLCDM'.indexOf(a);return
Math.pow(2,a>>1)*Math.pow(5,++a>>1)}
function Digit(a){a='IVXLCDM'.indexOf(a);return Math.pow(10,a>>1)*(a&1?5:1)}

wszystkie _algorytmiczne_, ktory Ci sie najbardziej podoba? ;)

w dodatku to nie wszystkie metody, ale ciekawe,
ze jest ich az tyle na tak pozornie blache zagadnenie :)

> P.S.: jak Ci sie podoba moj boolean * 2 - 1 ? - pozbylem sie if-else ;)

ten zakres materialu uwazaj za opanowany ;)

pozdrawiam - v.
Technical Details
Message-ID: <b0700o$83b$1@news.tpi.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.internetia.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
References: <b06bao$cp7$1@news.tpi.pl> <b06hbj$jbk$1@news.tpi.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.internetia.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
From: "Vax" <vax@ircx.pl>
Newsgroups: pl.comp.lang.javascript
Subject: Re: szkolka
Date: Thu, 16 Jan 2003 20:07:42 +0100
Organization: Vax
Lines: 31
Message-ID: <b0700o$83b$1@news.tpi.pl>
References: <b06bao$cp7$1@news.tpi.pl> <b06hbj$jbk$1@news.tpi.pl>
Reply-To: "Vax" <vax@ircx.pl>
NNTP-Posting-Host: pd1.wroclaw.cvx.ppp.tpnet.pl
X-Trace: news.tpi.pl 1042744153 8299 213.76.90.1 (16 Jan 2003 19:09:13 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: Thu, 16 Jan 2003 19:09:13 +0000 (UTC)
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit