10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-07 06:33:39 +01:00
QCaml/common/lib/spin.ml

33 lines
725 B
OCaml
Raw Normal View History

2019-02-18 12:41:54 +01:00
2020-12-28 01:08:55 +01:00
(* Note :
* ~Alfa~ if written with an 'f' instead of 'ph' because it has the same number of
* letters as ~Beta~, so the alignment of the code is nicer. *)
2019-02-22 19:19:11 +01:00
2020-12-28 01:55:03 +01:00
(* [[file:~/QCaml/common/spin.org::*Type][Type:2]] *)
2020-12-28 01:08:55 +01:00
type t = (* m_s *)
| Alfa (* {% $m_s = +1/2$ %} *)
| Beta (* {% $m_s = -1/2$ %} *)
(* Type:2 ends here *)
2019-02-22 19:19:11 +01:00
2020-12-28 01:08:55 +01:00
(* Returns the opposite spin *)
2019-02-22 19:19:11 +01:00
2020-12-28 01:55:03 +01:00
(* [[file:~/QCaml/common/spin.org::*Functions][Functions:2]] *)
2020-12-28 01:08:55 +01:00
let other = function
| Alfa -> Beta
| Beta -> Alfa
let to_string = function
| Alfa -> "Alpha"
| Beta -> "Beta "
(* Functions:2 ends here *)
2020-12-28 01:55:03 +01:00
(* [[file:~/QCaml/common/spin.org::*Printers][Printers:2]] *)
2020-12-28 01:08:55 +01:00
let pp ppf t =
Format.fprintf ppf "@[%s@]" (to_string t)
(* Printers:2 ends here *)