Sha256: 5593b7838029e851b6f0a5fd6348c4ee81577a9d8b4cf827771e1dd17d369777

Contents?: true

Size: 798 Bytes

Versions: 396

Compression:

Stored size: 798 Bytes

Contents

(define-module (robot)
  #:export (build-robot
            robot-name
            reset-name)
  #:autoload (srfi srfi-1) (iota))

(define random-alpha-char
  (lambda ()
    (list-ref (map integer->char (iota 26 65)) (random 26))))

(define random-digit-char
  (lambda ()
    (list-ref (map integer->char (iota 10 48)) (random 10))))

(define gen-name
  (lambda ()
    (string
     (random-alpha-char)
     (random-alpha-char)
     (random-digit-char)
     (random-digit-char)
     (random-digit-char))))

(define build-robot
  (lambda ()
    (let ((robot (make-hash-table 2)))
      (hashq-set! robot 'name  (gen-name))
      robot)))



(define robot-name
  (lambda (robot)
    (hashq-ref robot 'name)))

(define reset-name
  (lambda (robot)
    (set! robot (hashq-set! robot 'name (gen-name)))))

Version data entries

396 entries across 396 versions & 1 rubygems

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