Re: Pass argument to function
You actually don't even need string-append here. The following should also work: (capture (docker inspect ,str)) Best wishes, -utz
Re: Pass argument to function
Unquoting worked! I spent so much time trying different variations and this worked: (capture ,(string-append "docker inspect " str))) Thanks. Brandon
Re: Pass argument to function
You're right. I confused characters , with ` during typing in the editor. Sorry for misunderstanding at my part. Am Fr., 10. März 2023 um 20:36 Uhr schrieb : > > > >> (capture ,(string-append "docker inspect " str))) > > doesn't work because of the same reason that you expressed. > > You would get "quasiquote not found" from the shell. > > Yes, it does, and no, you don't get "quasiquote not found" from this. >
Re: Pass argument to function
On Fri, 10 Mar 2023 20:15:13 +0300 Nevroz Arslan wrote: >> (capture ,(string-append "docker inspect " str))) > doesn't work because of the same reason that you expressed. > You would get "quasiquote not found" from the shell. Actually, no: $ csi -R shell -p '(capture ,(string-append "echo" " foo"))' foo All the best. Mario -- http://parenteses.org/mario
Re: Pass argument to function
(capture ,(string-append "docker inspect " str))) doesn't work because of the same reason that you expressed. You would get "quasiquote not found" from the shell. Yes, it does, and no, you don't get "quasiquote not found" from this.
Re: Pass argument to function
Hi utz and Brandon, > (capture ,(string-append "docker inspect " str))) doesn't work because of the same reason that you expressed. You would get "quasiquote not found" from the shell. As a workaround, execute procedure might be used straightly. (define (inspect str) (execute (list (string-append "docker inspect " str)) 'verbose: #t )) Cheers, Am Fr., 10. März 2023 um 19:22 Uhr schrieb : > Hi Brandon, > > 'capture' and its friends 'run' and 'run*' are macros that treat their > arguments differently from what you would expect from a regular procedure. > > Looking at the documentation of '(run COMMAND ...)', you will find that > > > COMMAND is also implicitly quasiquoted so subexpressions may be > computed at run-time by unquoting them. > > which means that COMMAND is passed to the shell as-is, without being > evaluated. So the "not found" error is actually returned by the shell, > since it does not know what 'string-append' is. > > In order to evaluate a quasi-quoted expression (or parts of it), you > must unquote it (or the parts in question). > This should work: > > (capture ,(string-append "docker inspect " str))) > > Hope that helps. > > Best wishes, > -utz > >
Re: Pass argument to function
Hi Brandon, 'capture' and its friends 'run' and 'run*' are macros that treat their arguments differently from what you would expect from a regular procedure. Looking at the documentation of '(run COMMAND ...)', you will find that COMMAND is also implicitly quasiquoted so subexpressions may be computed at run-time by unquoting them. which means that COMMAND is passed to the shell as-is, without being evaluated. So the "not found" error is actually returned by the shell, since it does not know what 'string-append' is. In order to evaluate a quasi-quoted expression (or parts of it), you must unquote it (or the parts in question). This should work: (capture ,(string-append "docker inspect " str))) Hope that helps. Best wishes, -utz
Re: Pass argument to function
Hi Brandon, What you are doing looks right to me. What exactly is the error message? "string-append" is automaticalli imported, so it should be available without any imports. Perhaps you redifined "string-append" elsewhere in your code? If not, there may me a problem with your CHICKEN installation. ~> rlwrap csi #;1> (list "a" "b") ("a" "b") #;2> (list "a" (string-append "b" "c")) ("a" "bc") K. On Fri, Mar 10, 2023, 15:15 Brandon Booth wrote: > I'm trying to learn Chicken and having issues. I'm trying to create a > function that takes a docker container name and runs "docker inspect > [container]." > > This works: > (define test (capture "docker inspect hello-world")) > > This works: > (define (str-concat str) > (string-append "docker inspect " str)) > > This doesn't: > (define (inspect str) > (capture (string-append "docker inspect " str))) > > I get an error that string-append is not found. How do a call capture with > the result of string-append? > > Thanks. > > Brandon > > >
Pass argument to function
I'm trying to learn Chicken and having issues. I'm trying to create a function that takes a docker container name and runs "docker inspect [container]." This works: (define test (capture "docker inspect hello-world")) This works: (define (str-concat str) (string-append "docker inspect " str)) This doesn't: (define (inspect str) (capture (string-append "docker inspect " str))) I get an error that string-append is not found. How do a call capture with the result of string-append? Thanks. Brandon