simple question

7 views
Skip to first unread message

Neal Becker

unread,
Jul 14, 2010, 1:40:48 PM7/14/10
to le...@googlegroups.com
with Separator(spaces):
e = Integer() >> int
rest = Drop('[') & e[1:] & Drop(']\n') > list
stuff = e & rest > list

>>> stuff.parse ('0 [1 2 3]\n')
Out[3]: [[0, [1, 2, 3]]]

I wanted [0, [1,2,3]]. I don't want/understand why I have an extra level of
list.

andrew cooke

unread,
Jul 14, 2010, 1:58:30 PM7/14/10
to le...@googlegroups.com

Ah, the extra list... :o)

It's needed because internally there always has to be something to hold
results together. If you hadn't added an extra list on the outside of
everything, what would have wanted returned? Lepl can't return "0, [1,2,3]"
so it has to have a list itself. Then you added another!

I feel your pain - I did chase this around at one point, but I couldn't find
anything simpler. If I start adding special cases then it gets confusing when
matchers are combined, etc.

Cheers,
Andrew

> --
> You received this message because you are subscribed to the Google Groups "lepl" group.
> To post to this group, send email to le...@googlegroups.com.
> To unsubscribe from this group, send email to lepl+uns...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/lepl?hl=en.
>

Jasper St. Pierre

unread,
Jul 14, 2010, 2:06:27 PM7/14/10
to le...@googlegroups.com
Reading this might help you: http://acooke.org/lepl/faq.html#faq-apply

That FAQ entry is one of the most useful pieces of documentation since
it explains about how LEPL deals with lists of results and because
how ">" and ">>" are so crucial and core to LEPL.

LEPL already puts results in lists, so the "> list" is already extraneous.

andrew cooke

unread,
Jul 14, 2010, 3:08:12 PM7/14/10
to le...@googlegroups.com

lo inicie, pero es super-lento. ya tienes la mitad del primer archivo, en
3m. xxxxxxxxx

andrew cooke

unread,
Jul 14, 2010, 4:24:18 PM7/14/10
to le...@googlegroups.com
On Wed, Jul 14, 2010 at 03:08:12PM -0400, Andrew Cooke wrote:
>
> lo inicie, pero es super-lento. ya tienes la mitad del primer archivo, en
> 3m. xxxxxxxxx

Ooops. Sorry about that - replied to wrong email. Andrew

Reply all
Reply to author
Forward
0 new messages