Hi Stephen,

thanks for yoru reply ! ::)

At the certain point of the program I get
a list as parameter 'lst', which contains
the sublists of strings. I wrote this
function:


(define (to-txt lst)
  (if (empty? lst)
    lst
    (let ((line (car lst)))
      (begin
        (displayln (apply string-join line " " )) ;;; WRONG SYNTAX HERE
        (to-txt (cdr lst))))))

Since I get the sublists as parameters I need an 'apply' to 'inject'
(sorry...I am no native speaker...) 'string-join' into the list.

But string-join has additional parameters, and I dont know how to
combine those with 'apply'?

PS: The resulting strings will later be processed further... the
'displayln' is just a placeholder...

Cheers,
Meino


Stephen Chang <stch...@ccs.neu.edu> [16-10-29 17:16]:
> string-join already expects a list of strings, so are you sure you want apply?
> Can you give a more specific example?
> 
> Perhaps map or some other iteration is what you want?
> 
> (for ([strs '(("a" "b") ("c" "D" "E"))])
>   (displayln (string-join strs " ")))
> 
> =>
> a b
> c D E
> 
> On Sat, Oct 29, 2016 at 10:27 AM,  <meino.cra...@gmx.de> wrote:
> > Hi,
> >
> > ...still improving my shortwave-broadcaster-dumper... :)
> >
> > I have a list with sublists of strings, which I want to concatenate.
> > Each sublist shall form one line of output.
> > I tried 'string-append', but this gives me something like this
> > (excerpt):
> > "189RikisutvarpidRas1+20000-24001234567Icelandic"
> > ...the separating #\space is missing.
> >
> > The according code looks like this (excerpt)
> >
> > (apply string-append sublist)
> >
> > then I found 'string-join' which has extra-parameters
> > to define separator of all kinds.
> >
> > ...but...how can I express the 'apply'-instruction...with the
> > addional parameters???
> >
> > This looks something inbetween funny and weird:
> >
> > (apply string-join sublist " ")
> >
> > and racket mumbles:
> > apply: contract violation
> >   expected: list?
> >   given: " "
> >   argument position: 3rd
> >   other arguments...:
> >    #<procedure:string-join>
> >
> >
> > ?
> >
> > Cheers
> > Meino
> >
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to