Public Vars

Back

abs (clj)

(source)

function

(abs a)
Returns the absolute value of a. If a is Long/MIN_VALUE => Long/MIN_VALUE If a is a double and zero => +0.0 If a is a double and ##Inf or ##-Inf => ##Inf If a is a double and ##NaN => ##NaN

Examples

clojure
(ns clojure.test-clojure.reducers
  (:require [clojure.core.reducers :as r]
            [clojure.test.generative :refer (defspec)]
            [clojure.data.generators :as gen])
  (:use clojure.test))

(defequivtest test-map
  [map r/map #(into [] %)]
  [inc dec #(Math/sqrt (Math/abs %))])
mikera/core.matrix
(ns clojure.core.matrix.macros-clj
  "Namespace for core.matrix macros. Keeping them separate allows us to do conditional
  macros that can handle the differences between Clojure and Clojurescript."
  (:require [clojure.core.matrix.macros :refer [TODO c-for]])
  (:import [java.util Arrays]))

(defmacro eps== [a b eps]
  `(<= (Math/abs (- (double ~a) (double ~b))) (double ~eps) ))
hraberg/deuce
(ns deuce.emacs.floatfns
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [deuce.emacs.alloc :as alloc])
  (:refer-clojure :exclude [float]))

(defun abs (arg)
  "Return the absolute value of ARG."
  (if (float? arg)
    (Math/abs (double arg))
    (Math/abs (long arg))))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/abs (t/IFn #?(:clj [Long :-> Long])
              #?(:clj [Double :-> Double])
              [t/Num :-> t/Num])

#?@(:cljs [] :default [
clojure.math.numeric-tower/floor (t/IFn [t/AnyInteger :-> t/AnyInteger]
                                        [t/Num :-> t/Num])
clojure.math.numeric-tower/abs (t/IFn [t/AnyInteger :-> t/AnyInteger]
                                      [t/Num :-> t/Num])
])
re-path/studio
(ns renderer.tools.arc
  (:require
   ["svg-path-bbox" :as svg-path-bbox]
   [clojure.core.matrix :as mat]
   [goog.math]
   [re-frame.core :as rf]
   [renderer.attribute.angle :as angle]
   [renderer.attribute.hierarchy :as hierarchy]
   [renderer.element.handlers :as element.h]
   [renderer.overlay :as overlay]
   [renderer.tools.base :as tools]
   [renderer.utils.pointer :as pointer]
   [renderer.utils.units :as units]))

(defmethod tools/drag :arc
  [{:keys [adjusted-pointer-offset active-document adjusted-pointer-pos] :as db}]
  (let [{:keys [stroke fill]} (get-in db [:documents active-document])
        [offset-x offset-y] adjusted-pointer-offset
        [pos-x pos-y] adjusted-pointer-pos
        attrs {:cx offset-x
               :cy offset-y
               ::start-deg 90
               ::end-deg 180
               :fill fill
               :stroke stroke
               :rx (abs (- pos-x offset-x))
               :ry (abs (- pos-y offset-y))}]
    (element.h/set-temp db {:type :element :tag :arc :attrs attrs})))

(defmethod tools/edit :arc
  [element [x y] handler]
  (case handler
    :rx (hierarchy/update-attr element :rx #(abs (+ % x)))
    :ry (hierarchy/update-attr element :ry #(abs (- % y)))
    element))
re-path/studio
(ns renderer.tools.page
  (:require
   [clojure.core.matrix :as mat]
   [clojure.string :as str]
   [goog.string :as g.str]
   [re-frame.core :as rf]
   [reagent.dom.server :as dom]
   [renderer.element.handlers :as element.h]
   [renderer.tools.base :as tools]
   [renderer.utils.pointer :as pointer]
   [renderer.utils.units :as units]))

(defmethod tools/drag :page
  [{:keys [adjusted-pointer-pos adjusted-pointer-offset] :as db} e]
  (let [[offset-x offset-y] adjusted-pointer-offset
        [pos-x pos-y] adjusted-pointer-pos
        lock-ratio? (contains? (:modifiers e) :ctrl)
        width (abs (- pos-x offset-x))
        height (abs (- pos-y offset-y))
        attrs {:x (min pos-x offset-x)
               :y (min pos-y offset-y)
               :width (if lock-ratio? (min width height) width)
               :height (if lock-ratio? (min width height) height)
               :fill "#ffffff"}]
    (element.h/set-temp db {:tag :page
                            :type :element
                            :name "Page"
                            :attrs attrs})))