Liking cljdoc? Tell your friends :D

sicmutils.abstract.number


abstract-number?clj/s

(abstract-number? x)

Returns true if x is:

  • a symbolic expression
  • some object wrapped by a call to `literal-number
  • a symbol (which implicitly acts as a literal number)

See literal-number? for a similar function that won't respond true to symbols, only to explicit symbolic expressions or wrapped literal numbers.

Returns true if `x` is:

- a symbolic expression
- some object wrapped by a call to `literal-number
- a symbol (which implicitly acts as a literal number)

See [[literal-number?]] for a similar function that won't respond true to
symbols, only to explicit symbolic expressions or wrapped literal numbers.
raw docstring

literal-numberclj/s

(literal-number x)

Returns its argument, wrapped in a marker type that responds to the generic operations registered in sicmutils.numsymb.

Symbols are automatically treated as literal-number instances, so

(* 10 (literal-number 'x))

is equivalent to

(* 10 'x).

If you pass an actual number, sicmutils will attempt to preserve exact values through various operations:

(g/+ 1 (g/cos (g/* 2 (literal-number 4)))) ;;=> (+ 1 (cos 8))

Notice that the (g/* 2 ...) is evaluated, but cos evaluation is deferred, since the result is inexact. On the other hand, if the number is inexact to begin with:

(g/+ 1 (g/cos (g/* 2 (literal-number 2.2)))) ;;=> 0.6926671300215806

the system will go ahead and evaluate it.

Returns its argument, wrapped in a marker type that responds to the generic
operations registered in `sicmutils.numsymb`.

Symbols are automatically treated as `literal-number` instances, so

(* 10 (literal-number 'x))

is equivalent to

(* 10 'x).

If you pass an actual number, sicmutils will attempt to preserve exact values
through various operations:

(g/+ 1 (g/cos (g/* 2 (literal-number 4))))
;;=> (+ 1 (cos 8))

Notice that the `(g/* 2 ...)` is evaluated, but `cos` evaluation is deferred,
since the result is inexact. On the other hand, if the number is inexact to
begin with:

(g/+ 1 (g/cos (g/* 2 (literal-number 2.2))))
;;=> 0.6926671300215806

the system will go ahead and evaluate it.
raw docstring

literal-number?clj/s

(literal-number? x)

Returns true if x is an explicit symbolic expression or something passed to literal-number, false otherwise.

See abstract-number? for a similar function that also responds true to symbols.

Returns true if `x` is an explicit symbolic expression or something passed to
`literal-number`, false otherwise.

See [[abstract-number?]] for a similar function that also responds true to
symbols.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close