Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Need a start point for resolving {[()]}

by hdb (Prior)
on Jun 13, 2013 at 07:21 UTC ( #1038695=note: print w/replies, xml ) Need Help??

in reply to Need a start point for resolving {[()]}

This piece of code could be a starting point. Also look at Re: Convert Tcl Keyed List to Perl where I use the same technique in a different context.

# node 1030367 use strict; use warnings; my $expr = '(A&(B&C)|((C&D)|\((A EQ 1)))'; my $level = 0; my $tab = "| "; my %action = ( '(' => sub { print "\n", $tab x ++$level, shift }, ')' => sub { print "\n", $tab x $level--, shift }, 'default' => sub { print shift }, ); ( $action{$_} // $action{'default'} )->($_) for $expr =~ /./g;

Replies are listed 'Best First'.
Re^2: Need a start point for resolving {[()]}
by exilepanda (Pilgrim) on Jun 13, 2013 at 11:39 UTC
    Wow! This inspires a lot, by level shifting and tabbing! A very nice start point! Looks much more neat and firm. Thanks for the lead!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038695]
[erix]: I should lose some weight although I keep telling myself that I'm doing extra training by lugging it along
[erix]: I saw a common kingfisher and a couple of bullfinches
[erix]: bullfinch ( a male and a female )
erix learned the word 'portaging' not so long ago (from vikings lugging their ships from one river-system to another)
[choroba]: my best run so far
[erix]: I think they build a portaging installation for yachts here not so long ago - lemme google it
[erix]: choroba ah, you should have sprinted 7 s off that :)

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2017-05-24 12:46 GMT
Find Nodes?
    Voting Booth?