Re: [speagram] Obs³uga liczb w kombinatorach.
Status: Alpha
Brought to you by:
lukaszkaiser
From: rzyjontko <rz...@op...> - 2004-09-04 09:55:01
|
Lukasz Kaiser wrote: >=20 > > digitsum (nat_float (nat_cons (m, d), 1)) >=20 > Jaki warunek ?=20 Warunek opisuj=B1cy dopasowanie si=EA termu do lewej strony regu=B3y przepisywania. =AFadna liczba nie dopasuje si=EA do termu=20 nat_float (nat_cons (m, d), 1). > Choc rzeczywiscie, liczenie sumy cyfr liczb typu floating point=20 > jest dosc malo powszechnym zajeciem. Ale po co je liczysz? Ale wykluczanie u=BFy=E6 to nie jest rozwi=B1zanie. Chcesz, zmusza=E6 u=BFytkownika do szukania innych dr=F3g na osi=B1gni=EAcie celu? Musia=B3= by=B6 ka=BFdemu z osobna t=B3umaczy=E6, =BFe tak si=EA nie robi, bo tutaj podj=EA= ta zosta=B3a taka decyzja projektowa, =BFe tak nikt nie napisze. > > Samo nat_cons sugeruje, ??e liczba jest wi??ksza od 10, ale=20 > > wyk??adnik =3D=3D 1 sprawia, ??e liczba musi by?? jednocyfrowa. >=20 > Rzeczywiscie, rzutowanie jest zle, musze zmienic funkcje liczaca > wykladnik.=20 _Nic_ Ci to nie pomo=BFe. Podkre=B6lam: tego si=EA _nie da_ naprawi=E6 bez zmiany ca=B3ej reprezentacji. Nie obliczysz wyk=B3adnika, bo nie masz z czego: ta liczba nie ma warto=B6ci: to jest term - lewa strona regu=B3y przepisywania. Nie zawiera konkretnych cyfr, tylko zmienne. Jakiegokolwiek wyk=B3adnika nie u=BFyjesz: b=EAdzie =BCle. Ale nie mo=BFesz u=BFy=E6 zmiennej zamiast wyk=B3adnika, bo wtedy dopasuj=B1 si=EA r=F3wnie=BF liczby nieca=B3kowite. > Ale obsluge 3 roznych + to juz sam musisz dodac do handlerow. Z punktu widzenia generatora: + jest po prostu funkcj=B1, kt=F3ra si=EA nazywa +. Wyst=EApuje tylko po prawej stronie regu=B3 przepisywania i jest wklejany bez =BFadnego sprawdzania jakie s=B1 jego argumenty. > Moja propozycja jest taka, zeby zmienic kodowanie na: >=20 > cons_float (m, c) =3D m * 10^c To niewiele zmienia. > No a przy kodowaniu r musisz niestety policzyc cyfry znaczace po > kolei. Najbardziej znaczaca cyfra r to chyba jest Jednym s=B3owem: iteracyjnie. Te=BF o tym my=B6la=B3em, dlatego na=20 pocz=B1tku zaproponowa=B3em, =BFe mo=BFe lepiej by by=B3o, gdyby interpre= ter kombinator=F3w potrafi=B3 obliczy=E6 cz=EA=B6=E6 u=B3amkow=B1 liczby jako= liczb=EA ca=B3kowit=B1 w zapisie dziesi=EAtnym. Ale ja najwy=BFej napisz=EA sobie w kombinatorach funkcj=EA, kt=F3ra to robi i tyle. --=20 rzyjontko http://www.student.ii.uni.wroc.pl/~rzyj/ |