Sha256: 59137ab742ee95015763265306bc6285204531991db1e859ae5177c54e717c40

Contents?: true

Size: 477 Bytes

Versions: 396

Compression:

Stored size: 477 Bytes

Contents

(defmodule grains
  (export (square 1)
          (total 0)))

(defun 1- (n) (- n 1))

(defun 2^ (x) (trunc (math:pow 2 x)))

(defun square (n) (trunc (2^ (1- n))))

(defun total () (1- (square 65)))

;;; Naive, recursive approach
;;
;; (defun square (n) (square n 1))
;;
;; (defun square
;;   ([1 acc] acc)
;;   ([n acc] (square (- n 1) (* acc 2))))
;;
;; (defun total ()
;;   (lists:foldl
;;     (lambda (x acc)
;;       (+ (square x) acc))
;;     0
;;     (lists:seq 1 64)))

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.179 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.178 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.177 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.176 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.175 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.174 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.173 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.172 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.171 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.170 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.169 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.167 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.166 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.165 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.164 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.163 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.162 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.161 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.160 tracks/lfe/exercises/grains/src/example.lfe