Sha256: 2acf850f387b1cb29784974a256a07b90b41e0a42fe593934f62e85c4e151838

Contents?: true

Size: 541 Bytes

Versions: 396

Compression:

Stored size: 541 Bytes

Contents

;;; difference-of-squares.el --- Difference of Squares (exercism)

;;; Commentary:

;;; Code:
(eval-when-compile (require 'cl))

(defun sum-of-squares (n)
  "Square of sums of N."
  (reduce #'+ (mapcar #'(lambda (i) (expt i 2)) (number-sequence 1 n))))

(defun square-of-sums (n)
  "Sum of squares of N."
  (expt (reduce #'+ (number-sequence 1 n)) 2))

(defun difference (n)
  "Difference of squares pertaining to N."
  (- (square-of-sums n)
     (sum-of-squares n)))

(provide 'difference-of-squares)
;;; difference-of-squares.el ends here

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.179 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.178 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.177 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.176 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.175 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.174 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.173 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.172 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.171 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.170 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.169 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.167 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.166 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.165 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.164 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.163 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.162 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.161 tracks/elisp/exercises/difference-of-squares/example.el
trackler-2.2.1.160 tracks/elisp/exercises/difference-of-squares/example.el