From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Panicz Maciej Godek Newsgroups: gmane.lisp.guile.user Subject: Re: Help with lambda-procedure Date: Sun, 16 Dec 2018 21:31:56 +0100 Message-ID: References: <9821320835493e75e12418c00796312c@riseup.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1544992415 32622 195.159.176.226 (16 Dec 2018 20:33:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Dec 2018 20:33:35 +0000 (UTC) Cc: Guile User To: swedebugia@riseup.net Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Dec 16 21:33:31 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYd6P-0008NT-VO for guile-user@m.gmane.org; Sun, 16 Dec 2018 21:33:30 +0100 Original-Received: from localhost ([::1]:43691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYd8W-0007FA-J0 for guile-user@m.gmane.org; Sun, 16 Dec 2018 15:35:40 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYd7u-0007CG-2D for guile-user@gnu.org; Sun, 16 Dec 2018 15:35:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYd58-0003bH-5e for guile-user@gnu.org; Sun, 16 Dec 2018 15:32:11 -0500 Original-Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:34910) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gYd57-0003ZH-Gp for guile-user@gnu.org; Sun, 16 Dec 2018 15:32:10 -0500 Original-Received: by mail-ed1-x52a.google.com with SMTP id x30so9074131edx.2 for ; Sun, 16 Dec 2018 12:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CGS6zWpWmti1o+vUpuIUhCG5cu/QGYYhVRr6KO5UM3w=; b=pk7ChlbxKV6lSqI0VGQKB+f/sxObGZD2NZEy+694lnFLji1qRRejUc3/I7coqBSRKz JN5Xzq69cDH58MSnaPoJgndzNm2fC/IGx5ywtCwyUmtstMhck6y8uNLkwFjWajF1Vaf3 eKW7JZ33IMKuxdCOExhR8jPLmlcZ8Jj5OtNN7FVdSMOnqqbA7YhJTKaCuifInWjwWWmk 6sSy+u7w4f5ghaESaACLnlIPGRaglorePyqgo5aWpsCY7AVOaQLFOdqgbror+ixolt5I aNKHFA/TBUj5QlHXIojziX4OAlrSfQ9XOLc5Xw63y5GhlMerO58cRhzbuGwA8uQdNBFi R60Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CGS6zWpWmti1o+vUpuIUhCG5cu/QGYYhVRr6KO5UM3w=; b=gWj3TdKSyVcLQOT8g9IKVca92olNXb/ry19o5agnMBYnr6hVDmillhhvcC6AO8RHqd 0tT1AMgoHp4fxAcRPOx5tY4RsqofewkdHTPljz8YO+aQWQnqRQptpw3r8AdYLoKXP0QH REjL9D5zM8bK8aw0hEEMo+8g16adNKzTozoOeTVEAEOpVvt5nHfHNnNMN2w0HXrGb2iv MZUTrZon8u9bHs/Z90UPz7ur/rGYkMwpaaZgSW2B81GK+gPlyCwujByFnRsePIMtGZCm 4K3KAZOOWfr11k+XzXQMR682spmq8duscpPrL1JEIfYl5Kf/tnza9e2Td2sTWKADtBCe w5Ow== X-Gm-Message-State: AA+aEWa94oexrncq0BSNcLHTmb2ui39B3Lf1r0hbKgaVsb0PrRqWh6uC VsMAlHdLQGxSs5ZAo+WmVOazSOoj+9jPbQgPZrQ= X-Google-Smtp-Source: AFSGD/VRVtF7GBCTHA2/wy1dGS2PZ0WkrXwD/ZaAJl5sRyYacsh91lNcypnbcTKIC2yjBk/gSQpq5rRmHIYXkFN/QxM= X-Received: by 2002:a17:906:abd3:: with SMTP id kq19-v6mr8364752ejb.116.1544992324140; Sun, 16 Dec 2018 12:32:04 -0800 (PST) In-Reply-To: <9821320835493e75e12418c00796312c@riseup.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::52a X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15104 Archived-At: Hi, I don't have much time to look at this, but from a glimpse it seems that the cluprit is this line: (let* ((version (split (string-drop version 1))) it should probably be (let* ((version (split (string-drop (version) 1))) - version is a procedure that produces string, and string-drop expects a string (like the error says), not a procedure. niedz., 16 gru 2018 o 20:59 napisa=C5=82(a): > I'm trying hard to improve the npm-explorer[1] with a semver-parser. > > I get this error when testing in the REPL: > > sdb@antelope ~/src/guile-npm-explorer$ guile -s npm-explorer.scm > >test.dot > ;;; note: source file /home/sdb/src/guile-npm-explorer/npm-explorer.scm > ;;; newer than compiled > > /home/sdb/.cache/guile/ccache/2.2-LE-4-3.A/home/sdb/src/guile-npm-explore= r/npm-explorer.scm.go > ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 > ;;; or pass the --no-auto-compile argument to disable. > ;;; compiling /home/sdb/src/guile-npm-explorer/npm-explorer.scm > ;;; compiled > > /home/sdb/.cache/guile/ccache/2.2-LE-4-3.A/home/sdb/src/guile-npm-explore= r/npm-explorer.scm.go > Backtrace: > 7 (apply-smob/1 #) > In ice-9/boot-9.scm: > 705:2 6 (call-with-prompt _ _ #) > In ice-9/eval.scm: > 619:8 5 (_ #(#(#))) > 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 # #) > In unknown file: > 0 (string-prefix? "*" # # =E2= =80=A6) > > ERROR: In procedure string-prefix?: > In procedure string-prefix?: Wrong type argument in position 2 > (expecting string): # > > 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))) > (version-list > (map first > (hash-table->alist (hash-ref hashtable "versions")))) > (same-major > (if (equal? 3 (length version)) > (fold > ;; recurse through version-list > > > > (lambda (ver lst) > (if (string-prefix? (major version) ver) > (cons ver lst) > lst)) > '() > version-list) > ;; not a version triplet > > > > #f))) > ... (se the rest of the sexp in the file attached. > > Any ideas whats wrong? I'm still new to lambdas. > > -- > Cheers > Swedebugia > > [1] > > https://gitlab.com/swedebugia/guile-npm-explorer/blob/master/npm-explorer= .scm