[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with lambda-procedure

From: swedebugia
Subject: Help with lambda-procedure
Date: Sun, 16 Dec 2018 11:48:45 -0800

I'm trying hard to improve the npm-explorer[1] with a semver-parser.

I get this error when testing in the REPL:

address@hidden ~/src/guile-npm-explorer$ guile -s npm-explorer.scm
;;; note: source file /home/sdb/src/guile-npm-explorer/npm-explorer.scm
;;;       newer than compiled
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/sdb/src/guile-npm-explorer/npm-explorer.scm
;;; compiled
           7 (apply-smob/1 #<catch-closure 88f83a0>)
In ice-9/boot-9.scm:
    705:2  6 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8  5 (_ #(#(#<directory (guile-user) 88e9910>)))
In ice-9/boot-9.scm:
   2312:4  4 (save-module-excursion _)
  3831:12  3 (_)
In /home/sdb/src/guile-npm-explorer/npm-explorer.scm:
   345:29  2 (generate-dot "mocha" () 0 _)
    199:8  1 (choose-version #<hash-table 8918540 18/31> #<procedure…>)
In unknown file:
           0 (string-prefix? "*" #<procedure version ()> #<undefined> …)

ERROR: In procedure string-prefix?:
In procedure string-prefix?: Wrong type argument in position 2
(expecting string): #<procedure version ()>

The offending lambda is this one:

(define (parse-semver hashtable version)
  "return the newest version within the same major or minor version"
  (define (split list)
    (string-split list #\.))
  (define (version-list hashtable)
    (map split
         (map first
              (hash-table->alist (hash-ref hashtable "versions")))))
  (define (major list)
    (first list))
  (define (minor list)
    (second list))
  (define (minor->number list)
    (string->number (minor (split list))))
  ;; Return latest minor with same major version.                       
  ;; e.g. ^1.1.0 -> 1.4.0 even though 2.0.0 is availiable               
  (let* ((version (split (string-drop version 1)))
          (map first
               (hash-table->alist (hash-ref hashtable "versions"))))
          (if (equal? 3 (length version))
               ;; recurse through version-list                          
               (lambda (ver lst)
                 (if (string-prefix? (major version) ver)
                     (cons ver lst)
              ;; not a version triplet                                  
... (se the rest of the sexp in the file attached.

Any ideas whats wrong? I'm still new to lambdas.



Attachment: npm-explorer.scm
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]