--- loncom/homework/templates/sampleexternal.problem 2010/12/20 18:14:18 1.1
+++ loncom/homework/templates/sampleexternal.problem 2012/02/04 15:12:40 1.4
@@ -10,18 +10,29 @@ sub fact {
}
$testvalues='0=1';
-for ($i=1,3) {
+foreach $i (1..3) {
$rand=&random(3,8,1);
$testvalues.=','.$rand.'='.&fact($rand);
}
+
+%args=('somecode' => (<<'ENDCODE')
+sub negative {
+ my ($number)=@_;
+ return $number<0;
+}
+ENDCODE
+);
+
+
-Write a Perl subroutine called factorial, which returns the factorial of its argument, e.g. &factorial(17)=17!.
+Write a Perl subroutine called factorial, which returns the factorial of its argument, e.g. &factorial(17)=17!. You can use the
+boolean function &negative(number), which returns true if the argument is negative.
Sample code for an evaluation script can be found here.
-
+