> NOTE: I’ve already been called out for Treb not having tests. No, it doesn’t, I wouldn’t argue if it began acquiring them, but it doesn’t have tests written for it because it’s a child of a rapid-startup-culture web application. I plan on writing up another blog post about that soon.
@webarto Two weeks ago I was even willing to held a talk about WP as somebody had asked for that. But that person didn't show up for the whole conference. I mean it can be fun, but if you don't take it lightly, it's just a one-way thingy.
@hakra WP can bring money for relatively little knowledge, and I hate that PHP == WP, makes us look bad... Why don't they make WP4 that is OO and sane...
Okay I now put the parameters and the builder into one class. I thought it's okay because it's pretty compact and related enough anyway. Also I didn't want to make the example too complicated:
If I read your question right, you are looking for a so called Query-Builder. A query builder is a class that has some parameters and which can return the query based on the parameters.
Actually this needs nothing more and nothing less if the example you have above is what you need. You only nee...
@webarto Well I would not even say that all this is bad and such and any project with some history has stories to tell. And OOP isn't the end of the flagpole. Those who think will loose a lot in programming.
Hey people. For example, there are 3 people and each one has a random generated number. I would like to print out the names of those people from biggest to smallest number. Is there any different way instead of just using if clauses? It gets a little hard to maintain where it comes to more 'people'. For real i need it for printing out the benchmarking results. Thanks
the thing is like this, in the profile, the left hand side will show the post by the user and the number of comments associated with the post, if the user click clicks on the number of comments, it is going to show the comments. what i am doing is if the user is in http://mysite.com/profile.php?user_id$userid; then the url for the no. of coments is http:/mysite.com/getcomment.php?commntid=$commentid. so when thn user clicks, i want to return the comments rom getcomments.php using an array... is there a better way to display the comments without redirecting to any other page
An interesting problem solving problem for people to try:
Given a triangle:
1
2 3
4 5 6
Find the maximum total of all of the possible paths.
Ex: in this case, the max total is 10, 6 + 3 + 1...
Given a file input consisting of a format:
1
2 3
4 5 6
With 1000 rows (1000 levels), find the maximum total...
@orourkek When the pyramid is more than 2 rows the path could not be straight. The challenge is so find an intelligent method and not just brute-force it (which any idiot could, given enough CPU cycles)
i wrote a problem like this using C ( i mean we had to) when we studied trees n graph theory, but its not exactly the same as the problem being discussed
@ircmaxell you can reduce per line. one path wins there. in the end it is either left or right. so maximum of two times. you can ignore the first line as it is invariant
wait, we can carrange it as 1 2 3 4 5 6 and then start from the bottom row and compare each adjancent pairs . Take the bigger one and add it to the number above the pair
I have a big problem with jquery if condition:
I have a div and if user click on it, calling ajax and user put a data and submit form.
I check the input with jQuery and if it was OK send to another ajax form.
for the first time it work and if check the conditions but for the second time if user c...
@ircmaxell will this work we can carrange it as 1 2 3 4 5 6 and then start from the bottom row and compare each adjancent pairs . Take the bigger one and add it to the number above the pair
Question: I thought when you included a file ( include('config.php'); ) it would also include the variable values throughout the scope of the entire process. I found out that my configuration values from config.php weren't transfered when I tried to call on variables on a different script. Is there a way to pass variable values from one file to another, so a configuration file is possible?
it's about converting CSS selector into XPATH in the end, in between there should be some AST. Parser works, but just does not output any data-structure. But it would be useful to further on process ;)
@NikiC So if I make use of the visitor pattern within accept() and expect() I might be able to construct it if I keep the AST as the structure in a parallel context. So I exploit static state to create the data-structure.
Maybe I just need some good examples how to create an AST to wrap my head around it.
Also I have the feeling that using an S-Expression is good enough for the node tree.
@NikiC I can only return true or false so far for these. That is how parsing works. However, I could return FALSE and TRUE would be the partial AST. Good idea.
@ircmaxell codepad.org/q6bbCdIA Anything like the right answer? Seems to work, not sure though as have not thoroughly tested it. Assumes tree is a 0-indexed array of 0-indexed arrays with the top of the tree as the first element. PS Yeh, I got sucked in
@NikiC The work is not useless. The work needs to be done, it is parsing. And if the data-structure for the bare AST is not that expensive, the memory overhead should not be that high.
@NikiC While parsing, you do not know up to a certain point if or if not the current stack is the right one. So it is yet both TRUE and FALSE. Therefore, for TRUE, the AST strucutre need to be build until it's known that it is FALSE. So it is necessary to build it.
The only way around it I see is to first parse and then if you know there is a result, parse again but this time with AST building.
Or is a generated parser building all paths so it can execute each one with a single invoke? Then it would be as I wrote above. First parse and if successfull, parse again with creating the AST.
I think the parser I have currently is something of the Left whatever camp.
okay, LARL parser have some shortcoming here to which they exploit the path. My hand implemented parser has all paths so is truly unoptimized lookahead so does not have that shortcoming of the LARL parser.
However this means that I can not do that easily segmented look-aheads.
@hakra No, at least LALR does not. But it builds a proper state machine, so it can delay running the reduction methods until it knows something will match (or all won't)
> In a LR(1) parser the state sequence is correctly resolved to A3, because the lookahead information has been preserved through the detailed rule system. In a LALR parser the state sequence cannot be resolved because the parser encounters a duplicate rule, which is an error. The above grammar will be declared ambiguous by a LALR parser generator.
$tree = array(
array(1),
array(2,3),
array(5, 4, 6),
);
$k=count($table)-2;
for($i=$k;$i>=0;$i--)
{
foreach($table[$i] as $j =>$maxval)
$maxval=$maxval+max($table[$i][$j],$table[$j+1]);
}
echo $maxval;
i wrote it.... although i am a very fast coder
@ircmaxell http://codepad.org/q6bbCdIA Anything like the right answer? Seems to work, not sure though as have not thoroughly tested it. Assumes tree is a 0-indexed array of 0-indexed arrays with the top of the tree as the first element. PS Yeh, I got sucked in
@ircmaxell you can reduce per line. one path wins there. in the end it is either left or right. so maximum of two times. you can ignore the first line as it is invariant
if i write
$t=array(array());
$t[0][0]=$cmntid;
$t[0][1]=$comment;
$t[1][0]=$cmntid2;
$t[1][1]=$comment2;
then what will be the return statement to return the 2d array
well, i cudnot solve it, i need to display only the comments for a post, for which he opts out
for example, if there are the posts
A says hi
3 comments
A says hello
2 comments
A says bye
1 comment
now if the user clicks on 2 comments, it will display
A says hi
3 comments
A says hello
b says hey
c says long time
A says bye
1 comment
i need an idea............to solve this