From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hartmut Goebel Newsgroups: gmane.lisp.guile.user Subject: Simple list of key-value pairs? Date: Thu, 8 Jul 2021 16:37:09 +0200 Organization: crazy-compilers.com Message-ID: <410e7168-3709-c961-c894-d534782ef526@crazy-compilers.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28606"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Jul 08 16:37:56 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1VA3-0007Dm-H1 for guile-user@m.gmane-mx.org; Thu, 08 Jul 2021 16:37:55 +0200 Original-Received: from localhost ([::1]:48478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1VA2-0007Xi-IB for guile-user@m.gmane-mx.org; Thu, 08 Jul 2021 10:37:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1V9R-0007TS-8j for guile-user@gnu.org; Thu, 08 Jul 2021 10:37:17 -0400 Original-Received: from mail-out.m-online.net ([212.18.0.9]:53179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1V9P-0002d3-1N for guile-user@gnu.org; Thu, 08 Jul 2021 10:37:17 -0400 Original-Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4GLJlr6fZ8z1qtQN for ; Thu, 8 Jul 2021 16:37:12 +0200 (CEST) Original-Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4GLJlr5syFz1qwZ5 for ; Thu, 8 Jul 2021 16:37:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Original-Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id W5yvg5G2Anhk for ; Thu, 8 Jul 2021 16:37:11 +0200 (CEST) Original-Received: from hermia.goebel-consult.de (ppp-188-174-62-244.dynamic.mnet-online.de [188.174.62.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS for ; Thu, 8 Jul 2021 16:37:11 +0200 (CEST) Original-Received: from thisbe.goebel-consult.de (hermia.goebel-consult.de [192.168.110.7]) by hermia.goebel-consult.de (Postfix) with ESMTP id EFD30601EF for ; Thu, 8 Jul 2021 16:37:19 +0200 (CEST) Content-Language: en-US Received-SPF: none client-ip=212.18.0.9; envelope-from=h.goebel@crazy-compilers.com; helo=mail-out.m-online.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17642 Archived-At: Hi, I'm seeking advice for passing simple key-value pairs to a function and generate a string out of these values. Neither the names not the number of keys is known in advance. Background: This shall become a generic function for generating URI query-strings. My current approach please see below. Anyhow, I'm wondering whether the quite and quasiquote can be replaced by something simpler. (use-modules (ice-9 match)) (define limit 100) (define evaluation "linux") (define* (api-uri base path #:rest query)   (define (build-query-string kv)     (match kv        ((name #f) #f)        ((name (? string? value))         (string-append name "=" value))  ; FIXME: encode        ((name (? number? value))         (string-append name "=" (number->string value)))))   (format #t "~%Query: ~a~%~%" query)   (let ((query-string      (when query        (string-join         (filter (lambda (x) x) (map build-query-string query))         "&"))))     (format #t "~%Query-String: ~a~%~%" query-string)     ;; todo: build uri incl. query-string   )) (api-uri "https://ci.guix.gnu.org" "/api/jobs") (api-uri "https://ci.guix.gnu.org" "/api/jobs"      `("nr" ,limit)      `("evaluation" ,evaluation)      `("system" ,#f)) -- Regards Hartmut Goebel | Hartmut Goebel | h.goebel@crazy-compilers.com | | www.crazy-compilers.com | compilers which you thought are impossible |