The jp-numeral Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The jp-numeral Reference Manual

This is the jp-numeral Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Wed Feb 19 20:48:18 2020 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Abstract

Common Lisp で漢数字を出すというネタパッケージ。cl:format との統合も可能。

This is a fun package for printing numbers as Japanese numerals. This can be integrated with cl:format.

License

The MIT License. See LICENSE file.

Loading

Loading by quicklisp

Quicklisp

(ql:quickload "jp-numeral")

or, Loading manually

Libraries depending on

Loading

(asdf:load-asd "jp-numeral.asd")
(asdf:load-system :jp-numeral)

For running tests, do below additionally.

(asdf:load-asd "jp-numeral-test.asd")
(asdf:test-system :jp-numeral)

Examples

通常の漢数字を出力する / Puts as (normal) Japanese numerals.

CL-USER> (format nil "~/jp-numeral:jp/" 12345687890)
"百二十三億四千五百六十八万七千八百九十"

CL-USER> (format nil "~/jp-numeral:jp/" 123/4567)
"四千五百六十七分の百二十三"

CL-USER> (format nil "~/jp-numeral:jp/" -0.0245)
"マイナス二厘四毛五糸"

割合や円として出力 / Puts as rate or yen.

割合として。

Puts as a rate (using ).

CL-USER> (format nil "~/jp-numeral:wari/" 0.123)
"一割二分三厘"

円として。

Puts as yen ().

CL-USER> (format nil "~/jp-numeral:yen/" 12000.67)
"一万二千円六十七銭"

大字を使用する / Puts as formal numbers.

: 修飾子を使用する。

Use : modifier.

CL-USER> (format nil "~:/jp-numeral:jp/" 12345687890)
"壱百弐拾参億四千五百六拾八万七千八百九拾"

大字で割合として。

Puts as a formal rate.

CL-USER> (format nil "~:/jp-numeral:wari/" 0.123)
"壱割弐分参厘"

大字で円として。

Puts as a formal yen.

CL-USER> (format nil "~:/jp-numeral:yen/" 12000.67)
"壱万弐千円六拾七銭"

旧字体を使用する / Puts with old glyphs.

@ 修飾子を使用する。

Use @ modifier.

CL-USER> (format nil "~@/jp-numeral:jp/" 12345687890)
"壹佰貳拾參億肆仟伍佰陸拾捌萬柒仟捌佰玖拾"

旧字体で割合として

Puts as a rate with old glyphs.

CL-USER> (format nil "~

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 jp-numeral

Author

YOKOTA Yuki <y2q.actionman@gmail.com>

License

MIT

Description

A printer for Japanese numerals.

Dependencies
Source

jp-numeral.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 jp-numeral/src

Parent

jp-numeral (system)

Location

src/

Components

Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 jp-numeral.asd

Location

jp-numeral.asd

Systems

jp-numeral (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.2 jp-numeral/src/package.lisp

Parent

src (module)

Location

src/package.lisp

Packages

jp-numeral


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.3 jp-numeral/src/jp-numeral-table.lisp

Dependency

package.lisp (file)

Parent

src (module)

Location

src/jp-numeral-table.lisp

Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

4.1.4 jp-numeral/src/jp-numeral.lisp

Dependency

jp-numeral-table.lisp (file)

Parent

src (module)

Location

src/jp-numeral.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

5.1 jp-numeral

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Functions

Function: format-jp-numeral STREAM OBJECT STYLE &key DIGITS-AFTER-DOT SCALE RADIX-POINT

This function works same as ‘jp’, but arranges the arguments for convenience of calling from ordinary functions.
This writes OBJECT into STREAM as Japanese numerals with the style specified by STYLE.

Arguments are same as ‘jp’, except below:

- STYLE

Specify the style of output. Pass one of these symbols:

- ‘:normal’ :: Use normal Japanese numerals.
- ‘:formal’ :: Use formal styles.
- ‘:old’ :: Use old glyphs.
- ‘:positional’ :: Use positional notations.

====

‘jp’ と同じことを行うが、普通の関数として呼び出すのに便利なように
引数を置きかえている。
STYLE で指定した形式で、 STREAM に OBJECT を書き出す。

以下の引数以外は、‘jp’ の引数と同様。

- STYLE

出力形式を指定する。以下のいずれかのシンボルを渡す。

- ‘:normal’ :: 一般的な漢数字を使用する。
- ‘:formal’ :: 大字を使用する。
- ‘:old’ :: 旧字体を使用する。
- ‘:positional’ :: 位取り記数法を使用する。

Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: jp STREAM OBJECT &optional COLON-P AT-SIGN-P DIGITS-AFTER-DOT SCALE RADIX-POINT

This function writes OBJECT into STREAM as Japanese numerals.
This can be called from ‘cl:format’ with ’~/’ directive.

Arguments are:

- STREAM

Output destination stream.

- OBJECT

The object to be outputted.

- COLON-P, AT-SIGN-P

COLON-P and AT-SIGN-P specify the style for printing.
The corresponding is below:

- (and (not colon-p) (not at-sign-p)) :: Use normal Japanese numerals. - (and colon-p (not at-sign-p)) :: Use formal styles.
- (and (not colon-p) at-sign-p) :: Use Old glyphs.
- (and colon-p at-sign-p) :: Use positional Notation.

- DIGITS-AFTER-DOT

Specifies how many digits putted after the radix point when printing a floating-point number.
When ‘nil’ is specified, uses an appropriate one.

- SCALE

When printing, uses a number mutiplied with (expt 10 scale).

- RADIX-POINT

Specifies a character or a string used as a radix point.

====

STREAM に OBJECT を漢数字として書き出す。
‘cl:format’ の ‘~/‘ での関数呼びだしでも使用できる。

引数:

- STREAM

出力先の stream

- OBJECT

出力する object

- COLON-P, AT-SIGN-P

二つの組み合わせで出力形式を指定する。対応は以下の通り:

- (and (not colon-p) (not at-sign-p)) :: 通常の漢数字
- (and colon-p (not at-sign-p)) :: 大字
- (and (not colon-p) at-sign-p) :: 旧字体
- (and colon-p at-sign-p) :: 位取り記数法

- DIGITS-AFTER-DOT

浮動小数点数を出力する時に、小数点の後に何桁目まで出力するか。
‘nil’ にすると、適当に十分な数で出す。

- SCALE

出力の時に、 (expt 10 scale) を掛けた値を出力する。

- RADIX-POINT

小数点に使用する、文字もしくは文字列。

Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: wari STREAM OBJECT &optional COLON-P AT-SIGN-P DIGITS-AFTER-DOT &aux STYLE

This function works like ‘jp’, but puts as a rate.
The output value is multiplied with 10, and ’割’ is used for the radix point.

Arguments are same as ‘jp’.

====

‘jp’ と同様だが、 割合として表示する。
10倍され、小数点に ’割’ を使用した値が表示される。

引数は ‘jp’ と同様。

Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: yen STREAM OBJECT &optional COLON-P AT-SIGN-P DIGITS-AFTER-DOT &aux STYLE

This function works like ‘jp’, but puts as a yen.
The output value is rounded on specified position, and printed until ‘1’ with ’円’, until ‘0.01’ with ’銭’, and until ‘0.001’ with ’厘’.

Arguments are same as ‘jp’, except below:

- DIGITS-AFTER-DOT

Specifies how many digits putted after a radix point. The default is 2. Only one of ‘0‘, ‘2‘, or ‘3‘ is available.

====

‘jp’ と同様だが、 円として表示する。
指定した桁で丸め、 ‘1’ の桁までは ’円’ で、 ‘0.01’ の桁までは ’銭’ で、 ‘0.001’ の桁は ’厘’ で表示する。

以下の引数以外は、‘jp’ の引数と同様。

- DIGITS-AFTER-DOT

小数点以下のどの桁まで表示するか指定する。デフォルトは 2。
‘0‘ , ‘2‘ , ‘3‘ のいずれかが使用できる。

Package

jp-numeral

Source

jp-numeral.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Constants

Constant: +digits+

A vector of (<normal> <formal> <old> <positional>)

Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +fraction-parts-of+

A vector of (<normal> <formal> <old> <positional>

Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +minus-sign+

A vector of (<normal> <formal> <old> <positional>

Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +power-hash-table+

An alist of (<power> . (<normal> <formal> <old> <positional>))

Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +radix-point+

A vector of (<normal> <formal> <old> <positional>

Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +sen+

A vector of (<normal> <formal> <old> <positional>

Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +table-formal-index+
Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +table-normal-index+
Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +table-old-index+
Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +table-positional-index+
Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +wari+

A vector of (<normal> <formal> <old> <positional>

Package

jp-numeral

Source

jp-numeral-table.lisp (file)

Constant: +yen+

A vector of (<normal> <formal> <old> <positional>

Package

jp-numeral

Source

jp-numeral-table.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Functions

Function: flag-to-style COLON-P AT-SIGN-P
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: float-sufficient-width FLT
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: get-digit N STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: get-minus-sign STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: get-parts-of STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: get-power N STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: get-radix-point STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: get-sen STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: get-wari STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: get-yen STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: make-digits4-string DIGITS4 STYLE BASE-POWER
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: print-jp-plus-integer STREAM OBJECT STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: stringify-float FLT DIGITS-AFTER-DOT SCALE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: style-to-index STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: translate-digit-char C STYLE
Package

jp-numeral

Source

jp-numeral.lisp (file)

Function: write-positional-from-string STREAM LISPSTR STYLE RADIX-POINT-STRING
Package

jp-numeral

Source

jp-numeral.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.3 Generic functions

Generic Function: write-jp-numeral STREAM OBJECT STYLE &key DIGITS-AFTER-DOT SCALE RADIX-POINT-STRING RADIX-POINT-REQUIRED-P &allow-other-keys
Package

jp-numeral

Source

jp-numeral.lisp (file)

Methods
Method: write-jp-numeral STREAM (OBJECT float) STYLE &key DIGITS-AFTER-DOT SCALE RADIX-POINT-STRING RADIX-POINT-REQUIRED-P
Method: write-jp-numeral STREAM (OBJECT ratio) STYLE &key DIGITS-AFTER-DOT SCALE RADIX-POINT-STRING RADIX-POINT-REQUIRED-P
Method: write-jp-numeral STREAM (OBJECT integer) STYLE &key DIGITS-AFTER-DOT SCALE RADIX-POINT-STRING RADIX-POINT-REQUIRED-P
Method: write-jp-numeral STREAM (OBJECT float) (STYLE (eql positional)) &key DIGITS-AFTER-DOT SCALE RADIX-POINT-STRING RADIX-POINT-REQUIRED-P
Method: write-jp-numeral STREAM (OBJECT ratio) (STYLE (eql positional)) &key DIGITS-AFTER-DOT SCALE RADIX-POINT-STRING RADIX-POINT-REQUIRED-P
Method: write-jp-numeral STREAM (OBJECT integer) (STYLE (eql positional)) &key DIGITS-AFTER-DOT SCALE RADIX-POINT-STRING RADIX-POINT-REQUIRED-P
Method: write-jp-numeral STREAM (OBJECT rational) STYLE &rest ARGS &key SCALE &allow-other-keys around
Method: write-jp-numeral STREAM OBJECT STYLE &key &allow-other-keys

Previous: , Up: Internal definitions   [Contents][Index]

6.2.4 Conditions

Condition: no-power-char-error ()
Package

jp-numeral

Source

jp-numeral.lisp (file)

Direct superclasses

error (condition)

Condition: not-formattable-error ()
Package

jp-numeral

Source

jp-numeral.lisp (file)

Direct superclasses

error (condition)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   J   L   M  
Index Entry  Section

F
File, Lisp, jp-numeral.asd: The jp-numeral․asd file
File, Lisp, jp-numeral/src/jp-numeral-table.lisp: The jp-numeral/src/jp-numeral-table․lisp file
File, Lisp, jp-numeral/src/jp-numeral.lisp: The jp-numeral/src/jp-numeral․lisp file
File, Lisp, jp-numeral/src/package.lisp: The jp-numeral/src/package․lisp file

J
jp-numeral.asd: The jp-numeral․asd file
jp-numeral/src: The jp-numeral/src module
jp-numeral/src/jp-numeral-table.lisp: The jp-numeral/src/jp-numeral-table․lisp file
jp-numeral/src/jp-numeral.lisp: The jp-numeral/src/jp-numeral․lisp file
jp-numeral/src/package.lisp: The jp-numeral/src/package․lisp file

L
Lisp File, jp-numeral.asd: The jp-numeral․asd file
Lisp File, jp-numeral/src/jp-numeral-table.lisp: The jp-numeral/src/jp-numeral-table․lisp file
Lisp File, jp-numeral/src/jp-numeral.lisp: The jp-numeral/src/jp-numeral․lisp file
Lisp File, jp-numeral/src/package.lisp: The jp-numeral/src/package․lisp file

M
Module, jp-numeral/src: The jp-numeral/src module

Jump to:   F   J   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   F   G   J   M   P   S   T   W   Y  
Index Entry  Section

F
flag-to-style: Internal functions
float-sufficient-width: Internal functions
format-jp-numeral: Exported functions
Function, flag-to-style: Internal functions
Function, float-sufficient-width: Internal functions
Function, format-jp-numeral: Exported functions
Function, get-digit: Internal functions
Function, get-minus-sign: Internal functions
Function, get-parts-of: Internal functions
Function, get-power: Internal functions
Function, get-radix-point: Internal functions
Function, get-sen: Internal functions
Function, get-wari: Internal functions
Function, get-yen: Internal functions
Function, jp: Exported functions
Function, make-digits4-string: Internal functions
Function, print-jp-plus-integer: Internal functions
Function, stringify-float: Internal functions
Function, style-to-index: Internal functions
Function, translate-digit-char: Internal functions
Function, wari: Exported functions
Function, write-positional-from-string: Internal functions
Function, yen: Exported functions

G
Generic Function, write-jp-numeral: Internal generic functions
get-digit: Internal functions
get-minus-sign: Internal functions
get-parts-of: Internal functions
get-power: Internal functions
get-radix-point: Internal functions
get-sen: Internal functions
get-wari: Internal functions
get-yen: Internal functions

J
jp: Exported functions

M
make-digits4-string: Internal functions
Method, write-jp-numeral: Internal generic functions
Method, write-jp-numeral: Internal generic functions
Method, write-jp-numeral: Internal generic functions
Method, write-jp-numeral: Internal generic functions
Method, write-jp-numeral: Internal generic functions
Method, write-jp-numeral: Internal generic functions
Method, write-jp-numeral: Internal generic functions
Method, write-jp-numeral: Internal generic functions

P
print-jp-plus-integer: Internal functions

S
stringify-float: Internal functions
style-to-index: Internal functions

T
translate-digit-char: Internal functions

W
wari: Exported functions
write-jp-numeral: Internal generic functions
write-jp-numeral: Internal generic functions
write-jp-numeral: Internal generic functions
write-jp-numeral: Internal generic functions
write-jp-numeral: Internal generic functions
write-jp-numeral: Internal generic functions
write-jp-numeral: Internal generic functions
write-jp-numeral: Internal generic functions
write-jp-numeral: Internal generic functions
write-positional-from-string: Internal functions

Y
yen: Exported functions

Jump to:   F   G   J   M   P   S   T   W   Y  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   +  
C  
Index Entry  Section

+
+digits+: Internal constants
+fraction-parts-of+: Internal constants
+minus-sign+: Internal constants
+power-hash-table+: Internal constants
+radix-point+: Internal constants
+sen+: Internal constants
+table-formal-index+: Internal constants
+table-normal-index+: Internal constants
+table-old-index+: Internal constants
+table-positional-index+: Internal constants
+wari+: Internal constants
+yen+: Internal constants

C
Constant, +digits+: Internal constants
Constant, +fraction-parts-of+: Internal constants
Constant, +minus-sign+: Internal constants
Constant, +power-hash-table+: Internal constants
Constant, +radix-point+: Internal constants
Constant, +sen+: Internal constants
Constant, +table-formal-index+: Internal constants
Constant, +table-normal-index+: Internal constants
Constant, +table-old-index+: Internal constants
Constant, +table-positional-index+: Internal constants
Constant, +wari+: Internal constants
Constant, +yen+: Internal constants

Jump to:   +  
C  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   J   N   P   S  
Index Entry  Section

C
Condition, no-power-char-error: Internal conditions
Condition, not-formattable-error: Internal conditions

J
jp-numeral: The jp-numeral system
jp-numeral: The jp-numeral package

N
no-power-char-error: Internal conditions
not-formattable-error: Internal conditions

P
Package, jp-numeral: The jp-numeral package

S
System, jp-numeral: The jp-numeral system

Jump to:   C   J   N   P   S