Hi All, A student asked me for a perl solution to the problem at the bottom.
I went for both Ruby and Perl solutions, and here's some thoughts: Perl sigils are cool and help understand the code. I really love them - BUT, I think they actually hurt readability on some cases. For example, I found ruby's *array.clone* far more readable than perl's [ @$array ] Also, I found it easier to use subroutine refs in perl than in Ruby (not sure that's a good thing - code came out less readable). OTOH, some things that surprised me in ruby: Ruby has too many number types (I had to use .to_f function to get floating point division). It's not possible in ruby to use a function before it is declared (forced me to write code at the bottom) Ruby has no labels (making it hard to break from the outer loop) All code (ruby + perl) is on a public gist: https://gist.github.com/2224433 Your comments and thoughts are very welcomed, Ynon --- Write a program that takes a list of numbers, a list of operators, and a goal; and tells the user which mathematical operations must be performed to reach the goal. For example, given the input: numbers: 2, 4, 6, 8 operators: +, -, *, / goal: 25 Program should produce the output: sol = (((2 / 8) + 6) * 4) ----
_______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
