Hi all,

...think, I have to apologize....

I screwed it up....it is a language (spoke one...not "programming" )
thing:
I read "List of strings" which in german is "Liste von Zeichenketten".
THIS expression means this:
"A" "B" "C"
(for example).
This applied to string-join in a germenglish head forms:
(string-join "A" "B" "C" "seperator")
But I had
(define lst (list "A" "B" "C"))
(string-join lst "seperator")

...so I thougt I need an "apply" to move the
string-join right in front of the "list of strings" (spoken language)
in the list of strings (racket-speak).

But despite of the nonsense I thought I now have learned
how to handle functions with additional arguments in case
of the need to 'apply' them. 
Thanks a lot Shu-Hung, for you help and the patience of all
who wanted de-confuse me ;)

(THANKS!)

Cheers,
Meino


Shu-Hung You <shh...@u.northwestern.edu> [16-10-29 18:08]:
> Hi Meino,
> 
> Could you give an example of lst or line? Unlike string-append, most of the 
> time
> string-join doesn't really require an 'apply'. As we can see:
> 
> > (string-append "a" "b" "c")
> "abc"
> > (string-join '("a" "b" "c") ":")
> "a:b:c"
> 
> While string-append takes all its arguments and concatenates them into a 
> string,
> string-join simply joins all the strings in its first argument (which
> should be a list of strings).
> So suppose we have 'line' to be a list of string, then string-append
> and string-join can
> be used as follows:
> 
> > (define line '("x" "y" "z"))
> > (apply string-append line)
> "xyz"
> > (string-join line " ")
> "x y z"
> 
> If string-join is really to be used with apply, then we need to first
> construct its arguments
> into a list. For instance, the first of example of string-join is turned into:
> 
> > (string-join '("a" "b" "c") ":")
> "a:b:c"
> > (apply string-join '(("a" "b" "c") ":"))
> "a:b:c"
> 
> Given 'line' to be a list of strings, we need to construct the
> separator as the second item in
> the argument list of string-join:
> 
> > (define line '("x" "y" "z"))
> > (apply string-join (list line " "))
> "x y z"
> 
> Best,
> Shu-Hung
> 
> On Sat, Oct 29, 2016 at 10:31 AM,  <meino.cra...@gmx.de> wrote:
> >
> > 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.
> 
> -- 
> 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