Annotation of loncom/homework/default_homework.lcpm, revision 1.4
1.1 harris41 1: # file name (temp): default_homework
2: # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
3: #
4: #
1.3 albertel 5: $RANDOMINIT=0;
6:
1.4 ! albertel 7: sub tex {
! 8: if ( $external::target eq "tex" ) {
! 9: #$SCRIPT_RESULT.=@_[0];
! 10: return @_[0];
! 11: } else {
! 12: #$SCRIPT_RESULT.=@_[1];
! 13: return @_[1];
! 14: }
! 15: }
! 16:
! 17: sub web {
! 18: if ( $external::target eq "tex" ) {
! 19: #$SCRIPT_RESULT.=@_[1];
! 20: return @_[1];
! 21: } else {
! 22: if ( $external::target eq "web") {
! 23: #$SCRIPT_RESULT.=@_[0];
! 24: return @_[0];
! 25: } else {
! 26: #$SCRIPT_RESULT.=@_[2];
! 27: return @_[2];
! 28: }
! 29: }
! 30: }
! 31:
! 32: sub problem {
! 33: $SCRIPT_RESULT.='1';
! 34: return '';
! 35: }
! 36:
1.1 harris41 37: sub hinton {
38: return 0;
39: }
40:
41: sub random {
42: my ($start,$end,$step)=@_;
1.3 albertel 43: if ( ! $RANDOMINIT ) { srand($external::randomseed); $RANDOMINIT=1; }
1.1 harris41 44: my $num=1+int(($end-$start)/$step);
45: my $result=$start + int(rand() * $num)*$step;
46: return $result;
47: }
48:
49: sub tan { sin($_[0]) / cos($_[0]) }
50: sub acos { atan2(sqrt(1 - $_[0] * $_[0]), $_[0] ); }
51: sub asin { atan2($_[0], sqrt(1- $_[0] * $_[0]) ); }
52:
53: sub html {
1.4 ! albertel 54: if ( $external::target eq "web" ) {
! 55: #$SCRIPT_RESULT.=@_[0];
! 56: return @_[0];
1.1 harris41 57: }
58: }
59:
60:
61: sub pow {return $_[0] ** $_[1]; }
62: sub ceil {return (($_[0]-int($_[0]))== 0.0) ? $_[0] : (int($_[0])+ 1); }
63: sub floor {return int($_[0]); }
64:
1.2 albertel 65: sub format {
66: my ($value,$fmt)=@_;
67: $SCRIPT_RESULT.=sprintf('%.'.$fmt,$value);
68: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>