Skip to content

Commit 855c0ee

Browse files
committed
Doc enhancement of srfi-94
1 parent f0bdb28 commit 855c0ee

2 files changed

Lines changed: 145 additions & 8 deletions

File tree

doc/corelib.texi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4088,8 +4088,7 @@ Returns an exact integer only if all the given numbers are exact integers.
40884088

40894089

40904090
@defun exp z
4091-
@defunx log z
4092-
@defunx log z1 z2
4091+
@defunx log z :optional base
40934092
@defunx sin z
40944093
@defunx cos z
40954094
@defunx tan z
@@ -4110,12 +4109,12 @@ R7RSではこれらの手続きは@code{(scheme inexact)}モジュールにあ
41104109
@code{exp} returns @i{e} raised to the power of @var{z}. The one-argument
41114110
version of @code{log} returns the natural logarithm of @var{z}.
41124111
The two-argument version of @code{log} is added in R6RS, and returns
4113-
base-@var{z2} logarithm of @var{z1}.
4112+
base @var{base} logarithm of @var{z}.
41144113
@c JP
41154114
@code{exp}は@i{e}の@var{z}乗を返します。
41164115
1引数の@code{log}は@var{z}の自然対数を返します。
41174116
2引数の@code{log}はR6RSで追加されたもので、
4118-
@var{z2}を底とした@var{z1}の対数を返します。
4117+
@var{base}を底とした@var{z}の対数を返します。
41194118
@c COMMON
41204119

41214120
@c EN

doc/modsrfi.texi

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5946,33 +5946,65 @@ However, only the tests using @code{check} and @code{check-ec} are counted.
59465946

59475947
@deftp {Module} srfi.94
59485948
@mdindex srfi.94
5949-
This module provides arithmetic functions specialized for exact integers
5950-
and reals. Similar to @code{scheme.fixnum} (@pxref{R7RS fixnum})
5949+
@c EN
5950+
This module provides arithmetic functions specialized for reals
5951+
and exact integers. Similar to @code{scheme.fixnum} (@pxref{R7RS fixnum})
59515952
and @code{scheme.flonum} (@pxref{R7RS flonum}) in a sense of restricting
59525953
types of range and domains, but this srfi procedures cover wider range
59535954
(e.g. @code{real-*} procedures can accept all real numbers include
59545955
exact integers, and @code{integer-*} procedures can accept both fixnums
59555956
and bignums).
5957+
@c JP
5958+
このモジュールは実数および正確な整数に特化した数値演算関数を提供します。
5959+
定義域や値域の型を制約するという意味では
5960+
@code{scheme.fixnum} (@ref{R7RS fixnum}参照) や
5961+
@code{scheme.flonum} ((@ref{R7RS flonum})参照) と似ていますが、
5962+
このSRFIの関数はそれらのモジュールよりは広い範囲をカバーします
5963+
(例えば@code{real-*}手続きは正確な整数を含めた全ての実数を
5964+
対象としますし、@code{integer-*}手続きはfixnumだけでなくbignumも
5965+
扱えます)。
5966+
@c COMMON
59565967

5968+
@c EN
59575969
This module is provided mostly for the completeness. Generally useful
59585970
procedures are already built-in, so you don't need to use this
59595971
module to use them. Furthermore, some SRFI-94 procedures have the
59605972
same name of Gauche's built-in but behave slightly differently, so
59615973
just importing everything from @code{srfi.94} may cause unexpected effect.
59625974
If you need certain srfi-94 specific procedures, we recommend you to import
59635975
them selectively.
5976+
@c JP
5977+
このモジュール自体は完全性のために用意してあります。
5978+
一般的に有用と思われる関数については組み込みになっているので、
5979+
わざわざこのモジュールをuseする必要はありません。
5980+
さらに、SRFI-94の手続きのいくつかはGaucheの組み込み手続きと同じ名前を
5981+
持ちながら振る舞いが他所う異なったりするので、
5982+
@code{srfi.94}をまるごとインポートすると思いがけない副作用があるかもしれません。
5983+
特定の、SRFI-94特有の手続きを使いたい場合は、それに絞ってインポートすることを
5984+
お勧めします。
5985+
@c COMMON
59645986

5987+
@c EN
59655988
The following procedures are built-in. @xref{Arithmetics} for the details.
5989+
@c JP
5990+
以下の手続きは組み込みになっています。詳しくは@ref{Arithmetics}を参照してください。
5991+
@c COMMON
59665992
@example
59675993
real-exp real-tan atan make-rectangular
59685994
real-ln real-asin real-sqrt make-polar
59695995
real-sin real-acos integer-expt
59705996
real-cos real-atan real-expt
59715997
@end example
59725998

5999+
@c EN
59736000
The following procedures are redefined in this module, shadowing
59746001
Gauche's built-in procedures. See the description
59756002
of each entry for the difference.
6003+
@c JP
6004+
以下の手続きはこのモジュールで定義され、インポートすると
6005+
組み込み手続きをシャドウします。違いについてはそれぞれの
6006+
エントリの記述を参照してください。
6007+
@c COMMON
59766008
@example
59776009
quotient modulo remainder mod abs
59786010
@end example
@@ -5981,29 +6013,54 @@ quotient modulo remainder mod abs
59816013
@defun real-log base x
59826014
[SRFI-94]
59836015
@c MOD srfi.94
6016+
@c EN
59846017
The arguments must be nonnegative reals. Returns logarithm of @var{x}
59856018
with base @var{base}, computed as
59866019
@code{(/ (real-ln x) (real-ln base))}.
59876020

59886021
Note that R7RS's @code{log} takes @var{x} first, then optional @var{base}.
59896022
Gauche doesn't provide this procedure as built-in to avoid confusion.
6023+
@c JP
6024+
引数は非負の実数でなければなりません。
6025+
@var{base}を底とする@var{x}の対数を@code{(/ (real-ln x) (real-ln base))}
6026+
で計算して返します。
6027+
6028+
R7RSの@code{log}は@var{x}を最初に取り、
6029+
省略可能な@var{base}で底を指定することに注意してください。
6030+
Gaucheがこの手続きを組み込みとして提供していないのは、
6031+
引数順の混乱を避けるためです。
6032+
@c COMMON
59906033
@end defun
59916034

59926035
@defun integer-sqrt n
59936036
[SRFI-94]
59946037
@c MOD srfi.94
6038+
@c EN
59956039
This is the same as @code{exact-integer-sqrt} (@pxref{Arithmetics}).
6040+
@c JP
6041+
これは@code{exact-integer-sqrt}と同じです
6042+
(@ref{Arithmetics}参照)。
6043+
@c COMMON
59966044
@end defun
59976045

59986046
@defun integer-log base k
59996047
[SRFI-94]
60006048
@c MOD srfi.94
6049+
@c EN
60016050
Both arguments must be exact integers, and @var{base} must be
60026051
positive, while @var{x} must be nonnegative.
60036052

60046053
Returns a maximum exact integer @var{n} such that @code{(<= (expt base n) k)}.
60056054

60066055
The order of arguments is the same as @code{real-log}---not @code{log}.
6056+
@c JP
6057+
引数は正確な整数でなければならず、@var{base}は正数、
6058+
@var{x}は非負でなければなりません。
6059+
6060+
@code{(<= (expt base n) k)}となるような最大の正確な整数@var{n}を返します。
6061+
6062+
引数の順序は@code{real-log}と同じ、すなわち@code{log}とは異なります。
6063+
@c COMMON
60076064

60086065
@example
60096066
(integer-log 2 1500) @result{} 10
@@ -6013,41 +6070,122 @@ The order of arguments is the same as @code{real-log}---not @code{log}.
60136070
@defun abs x
60146071
[SRFI-94]
60156072
@c MOD srfi.94
6073+
@c EN
60166074
While Gauche's built-in @code{abs} can take a non-real number
60176075
(in which case, it acts like @code{magnitude}), this version
60186076
throws an error.
6077+
@c JP
6078+
Gauche組み込みの@code{abs}は実数でない複素数を取ることができて、
6079+
その場合は@code{magnitude}のように振る舞いますが、
6080+
この手続きはエラーを投げます。
6081+
@c COMMON
60196082
@end defun
60206083

60216084
@defun quo n d
60226085
@defunx mod n d
60236086
@defunx rem n d
60246087
[SRFI-94]
60256088
@c MOD srfi.94
6089+
@c EN
60266090
Real version of @code{quotient}, @code{modulo}, and @code{remainder}
60276091
(@pxref{Arithmetics}).
60286092

60296093
Returns quotient, modulo, and remainder of @var{n} divided by @var{d}.
60306094
Arguments doesn't need to be integers. If both are exact, the result
60316095
is exact.
6096+
@c JP
6097+
@code{quotient}、@code{modulo}、@code{remainder}の実数への拡張版です。
6098+
6099+
@var{n}を@var{d}で割った時の商および余りを返します。
6100+
引数は整数である必要はありません。両方とも正確数であれば結果も正確数となります。
6101+
@c COMMON
60326102

6103+
@c EN
60336104
@code{quo} returns @code{(truncate (/ n d))}.
60346105
@code{rem} returns @code{(- n (* d (quo n d)))}.
60356106
@code{mod} returns @code{(- n (* d (floor (/ n d))))}.
6107+
@c JP
6108+
@code{quo}は@code{(truncate (/ n d))}を、
6109+
@code{rem}は@code{(- n (* d (quo n d)))}を、
6110+
そして@code{mod}は@code{(- n (* d (floor (/ n d))))}を返します。
6111+
@c COMMON
60366112

6037-
Note: R6RS introduced different divison operators, @code{div} and @code{mod}
6113+
@c EN
6114+
Note: R6RS defined different divison operators, @code{div}, @code{mod},
6115+
@code{div0}, and @code{mod0}
60386116
(@pxref{Arithmetics}).
60396117
They can take non-integer arguments, but unfortunately, they behave
6040-
differently from SRFI-94.
6118+
differently from SRFI-94. SRFI-94's @code{quo} behaves the same as
6119+
R6RS's @code{div0}, and SRFI-94's @code{rem} behaves the same as
6120+
R6RS's @code{mod0}.
6121+
@c JP
6122+
註: R6RSは異なる除算オペレータ、@code{div}、@code{mod}、
6123+
@code{div0}、および@code{mod0}を定義しました(@ref{Arithmetics}参照)。
6124+
これらも非整数を取ることができますが、残念なことに
6125+
SRFI-94とは振る舞いが異なります。SRFI-94の@code{quo}は
6126+
R6RSの@code{div0}と、SRFI-94の@code{rem}は
6127+
R6RSの@code{mod0}と、それぞれ同じふるまいです。
6128+
@c COMMON
6129+
6130+
@example
6131+
(quo 2/3 1/5) @result{} 3
6132+
(mod 2/3 1/5) @result{} 1/15
6133+
(rem 2/3 1/5) @result{} 1/15
6134+
6135+
(quo 2/3 -1/5) @result{} -3
6136+
(mod 2/3 -1/5) @result{} -2/15
6137+
(rem 2/3 -1/5) @result{} 1/15
6138+
6139+
(quo -2/3 1/5) @result{} -3
6140+
(mod -2/3 1/5) @result{} 2/15
6141+
(rem -2/3 1/5) @result{} -1/15
6142+
6143+
(quo -2/3 -1/5) @result{} 3
6144+
(mod -2/3 -1/5) @result{} -1/15
6145+
(rem -2/3 -1/5) @result{} -1/15
6146+
6147+
@c EN
6148+
;; For comparison- R6RS procedures
6149+
@c JP
6150+
;; 比較のため: R6RS手続き
6151+
@c COMMON
6152+
(use gauche.base)
6153+
(div 2/3 1/5) @result{} 3
6154+
(mod 2/3 1/5) @result{} 1/15
6155+
(div0 2/3 1/5) @result{} 3
6156+
(mod0 2/3 1/5) @result{} 1/15
6157+
6158+
(div 2/3 -1/5) @result{} -3
6159+
(mod 2/3 -1/5) @result{} 1/15
6160+
(div0 2/3 -1/5) @result{} -3
6161+
(mod0 2/3 -1/5) @result{} 1/15
6162+
6163+
(div -2/3 1/5) @result{} -4
6164+
(mod -2/3 1/5) @result{} 2/15
6165+
(div0 -2/3 1/5) @result{} -3
6166+
(mod0 -2/3 1/5) @result{} -1/15
6167+
6168+
(div -2/3 -1/5) @result{} 4
6169+
(mod -2/3 -1/5) @result{} 2/15
6170+
(div0 -2/3 -1/5) @result{} 3
6171+
(mod0 -2/3 -1/5) @result{} -1/15
6172+
@end example
60416173
@end defun
60426174

60436175
@defun quotient n d
60446176
@defunx modulo n d
60456177
@defunx remainder n d
60466178
[SRFI-94]
60476179
@c MOD srfi.94
6180+
@c EN
60486181
SRFI-94 version of these procedures throws an error if the arguments
60496182
are not exact integers. Otherwise they behave the same
60506183
as built-in (@pxref{Arithmetics}).
6184+
@c JP
6185+
SRFI-94のバージョンは、引数が正確な整数でなければエラーを投げます。
6186+
それ以外は組み込みと同じように振る舞います
6187+
(@ref{Arithmetics}参照)。
6188+
@c COMMON
60516189
@end defun
60526190

60536191

0 commit comments

Comments
 (0)