real-part(3scm)
π real-part(3scm) β real & imaginary parts, from the Scheme Programmer's Manual β¨
π NAME π
real-part, imag-part β real and imaginary parts of a complex number. yes bestie, that's literally the whole name section.
π LIBRARY π
Okay so these are the import lines, depending on which Scheme flavor you're living in:
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme complex)) ;R7RS, optional library
Pick your fighter, but keep the imports exact. π
β¨ SYNOPSIS β¨
(real-part z)
(imag-part z)
Two calls, that's it. No cap. π¦
π¦ DESCRIPTION π¦
If z is the complex number a+bi, then the real-part procedure returns a and imag-part returns b. literally the real one and the imaginary one, bestie.
π§ IMPLEMENTATION NOTES π§
See the notes in make-rectangular(3scm). that's the whole note β go read that page for the tea.
π RETURN VALUES π
These procedures return a single value, a real number. one value. real number. slay.
π EXAMPLES π
Okay bestie, examples time:
(real-part 1.1+2.2i) => 1.1 ;approximately
(imag-part 1.1+2.2i) => 2.2 ;approximately
(real-part -2+3i) => -2 or -2.0
(imag-part -2+3i) => 3 or 3.0
(imag-part 42) => 0 or 0.0
π«Ά COMPATIBILITY π«Ά
All R6RS implementations support complex numbers. Implementations of the other RnRS reports may or may not support complex numbers. In such cases these procedures will be missing. so if you can't find them, it's not you, it's the implementation π
π ERRORS π
This procedure can raise exceptions with the following condition types:
&assertion(R6RS) β The wrong number of arguments was passed or an argument was outside its domain.- R7RS β The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
βcatastrophicallyβ is doing a lot of work there, bestie.
π SEE ALSO π
iykyk π«Ά
β STANDARDS β
R4RS, IEEE Scheme, R5RS, R6RS, R7RS. standards queen behavior.
πΈ HISTORY πΈ
These procedures first appeared in R2RS, which got them from Common Lisp, where they are called realpart and imagpart. history? more like herstory, but make it Lisp.
π AUTHORS π
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/. periodt.
xoxo, your Scheme bestie π β this one's from the Scheme Programmer's Manual, dated 2022-04-07, page real-part(3scm). π
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2022 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms