Hi Ken,

thanks for your reply ! :)

The problem is much "simpler"... :)

You wrote the whole logic to dig into the strings in the sublists in
the big list.
That's already done and working

I am in search for doing this

(string-join '( "a" "b" "c") " " )  ;; ( "a" "b" "c") is the sublist

but in the context of apply:
(define (to-txt lst)
  (if (empty? lst)
    lst
    (let ((line (car lst)))
      (begin
        (displayln (apply string-join line " ")) ;; THIS IS THE WRONG SYNTAX!!!
        (to-txt (cdr lst))))))

...and printing the lines is only a intermediate result....the joined
strings will be processed further in a later stage of this program.
That's why I need a complete string with separators.

Cheers
Meino





Ken MacKenzie <deviloc...@gmail.com> [16-10-29 16:48]:
> Not 100% sure of what you're asking so if I got this wrong pseudo code it for 
> me.  Remember I am kind of new to racket but I will give it a go:
> 
> As I understand it you have a list of lists of strings perhaps like this...
> 
> (('this' 'is' 'one')('this' 'is' 'another')....('this' 'is' 'the' 'last'))
> 
> and you want to output as such
> 
> this is one
> this is another
> ....
> this is the last
> 
> 
> Ok so here is how I would do this
> 
> I will write this as 2 functions, from your main code you call the first 
> passing it ...
> 
> big-list = the whole list of lists
> 
> ;;in main loop
> (per-line big-list)
> 
> (define (per-line blist)
>   (cond
>     [(empty? blist) #f]
>     [else
>       (per-item (first blist))
>       (newline)
>       (per-line (rest blist))]))
> 
> (define (per-item slist)
>   (cond
>     [(empty? slist) #f]
>     [else
>       (display (first slist))
>       (display " ")
>       (per-item (rest slist))]))
> 
> That should be about it.  Double check me an ide about matched parens and 
> brackets.  I just eyeballed this real quick in the message.  But that is the 
> approach I would take for a simple proof.
> 
> An alternate approach is per-item accepts a string argument and returns the 
> string to per-line to display.  But if the end goal is quick output this is a 
> bout as concise + readable as I think I can make it.
> 
> Ken
> 
> 
> On Saturday, October 29, 2016 at 10:27:09 AM UTC-4, meino.cramer 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.

Reply via email to