-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #904 from lean-ja/Seasawher/issue888
Char 型を紹介する
- Loading branch information
Showing
4 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
https://raw.githubusercontent.com/lean-ja/lean-by-example/.* | ||
https://adam.math.hhu.de/#/g/leanprover-community/NNG4 | ||
https://lean-lang.org/* | ||
https://live.lean-lang.org/ | ||
https://reservoir.lean-lang.org/ | ||
https://dcbadge.limes.pink/api/server/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/- # Char | ||
`Char` 型は、Unicode 文字を表します。二重引用符 `"` ではなくてシングルクォート `'` で囲んで表されます。 | ||
-/ | ||
|
||
-- Char はシングルクォートで囲む | ||
#check ('a' : Char) | ||
#check ("a" : String) | ||
|
||
-- Unicode 文字を含む | ||
#check ('あ' : Char) | ||
#check ('∀' : Char) | ||
#check ('∅' : Char) | ||
|
||
/- `Char` は、以下のように [`structure`](../Declarative/Structure.md) として定義されています。 -/ | ||
|
||
--#-- | ||
-- Char の定義が変わっていないことを確認するためのコード | ||
/-- | ||
info: structure Char : Type | ||
number of parameters: 0 | ||
constructor: | ||
Char.mk : (val : UInt32) → val.isValidChar → Char | ||
fields: | ||
val : UInt32 | ||
valid : self.val.isValidChar | ||
-/ | ||
#guard_msgs in #print Char | ||
--#-- | ||
namespace Hidden --# | ||
|
||
structure Char where | ||
/-- Unicode スカラー値 -/ | ||
val : UInt32 | ||
|
||
/-- `val` が正しいコードポイントであること -/ | ||
valid : val.isValidChar | ||
|
||
end Hidden --# | ||
/- したがって `Char.val` 関数によりコードポイントを取得することができます。-/ | ||
|
||
#guard 'a'.val = 97 | ||
#guard '⨅'.val = 10757 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters