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.119 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.118 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.117 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.116 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.115 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.114 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.113 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.111 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.110 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.109 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.108 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.107 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.106 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.105 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.104 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.103 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.102 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.101 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.100 tracks/lfe/exercises/grains/src/example.lfe
trackler-2.2.1.99 tracks/lfe/exercises/grains/src/example.lfe