Re: [racket-users] Converting bulleted list to s-expression?

2018-08-18 Thread Andrew J
Thanks. That's a useful package to know and solves the parsing problem. Now 
I need to syntax transform the xexpr into my target minimal list. Time to 
dig into *Fear of Macros*.

A.

On Saturday, 18 August 2018 12:19:12 UTC+10, Shu-Hung You wrote:
>
> The markdown package by Greg Hendershott provides a parser that create 
> HTML like xexprs from a string. The rest would be easy. 
>
> https://docs.racket-lang.org/markdown/index.html 
>
>
>
> On Fri, Aug 17, 2018 at 8:31 PM, Andrew J  > wrote: 
> > Hi. In a little side project, I'm looking for an simple Racket-y way to 
> > transform a bulleted list into a tree structure, maybe like sxml. 
> > 
> > As an example, this... 
> > 
> > - a 
> >   - b c 
> >   - d e f 
> > - g h 
> > 
> > would get transformed into something like this... 
> > 
> > '(a (b c) (d e f (g h))) 
> > 
> > I can see a few ways to do this, from recursively counting indents, 
> right 
> > through to making a mini DSL (à la Beautiful Racket), but I'm wondering 
> what 
> > a minimal idiomatic solution might look like? 
> > 
> > 
> > A. 
> > 
> > -- 
> > 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...@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.


[racket-users] Converting bulleted list to s-expression?

2018-08-17 Thread Andrew J
Hi. In a little side project, I'm looking for an simple Racket-y way to 
transform a bulleted list into a tree structure, maybe like sxml.

As an example, this...

- a
  - b c
  - d e f
- g h

would get transformed into something like this...

'(a (b c) (d e f (g h)))

I can see a few ways to do this, from recursively counting indents, right 
through to making a mini DSL (à la *Beautiful Racket*), but I'm wondering 
what a minimal idiomatic solution might look like?


A.

-- 
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.


[racket-users] Re: Question about style

2018-08-11 Thread Andrew J
I typically use either threading or composition...

(require threading)
(define (foo x)
  (~> x 
f g h bar))

or

(define (foo x)
  ((compose bar h g f) x)


A.

On Sunday, 12 August 2018 00:11:19 UTC+10, Robert Heffernan wrote:
>
> Dear all, 
>
> I am new to Racket and only slightly less new to scheme & scheme-like 
> languages. 
>
> I have noticed myself often doing something like the following: 
>
> (define (foo x) 
>   (let* ([y (f x)] 
>  [z (g y)] 
>  [p (h z)]) 
> (bar p))) 
>
> Which could, of course, be written as 
>
> (define (foo x) 
>   (bar (h (g (f x) 
>
> Here's an example from something I was just working on: 
>
> (define (get-data input) 
>   (let* ([url-string (construct-url input)] 
>  [url (string->url url-string)] 
>  [port (get-pure-port url)]) 
> (read-json port))) 
>
> which, again, could be written as: 
> (define (get-data input) 
>   (read-json (get-pure-port (string->url (construct-url input) 
>
> My question is: is the way I'm writing things considered to be bad 
> style?  It feels like a hangover from more imperative-style programming 
> & the inclination to do one thing "per line".  On the other hand, it 
> often helps readability. 
>
> It might be, of course, that both versions amount to the same thing 
> after the interpreter has been at them. 
>
> Thanks and regards, 
> Bob Heffernan 
>

-- 
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.