File:  [LON-CAPA] / loncom / homework / default_homework.lcpm
Revision 1.2: download - view: text, annotated - select for diffs
Thu Oct 5 19:24:23 2000 UTC (23 years, 6 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- implemented format()
- can now return values from scripts throught the $SCRIPT_RESULT variable

# file name (temp): default_homework 
# used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
# 
#
sub hinton {
  return 0;
}

sub random {
  my ($start,$end,$step)=@_;
  my $num=1+int(($end-$start)/$step);
  my $result=$start + int(rand() * $num)*$step;
  return $result;
}

sub tan  { sin($_[0]) / cos($_[0]) }
sub acos { atan2(sqrt(1 - $_[0] * $_[0]), $_[0] ); }
sub asin { atan2($_[0], sqrt(1- $_[0] * $_[0]) );  }

sub html {
  if ( $external::target == "web" ) {
    $SCRIPT_RESULT.=@_[0];
  }
}


sub pow   {return $_[0] ** $_[1]; }
sub ceil  {return (($_[0]-int($_[0]))== 0.0) ? $_[0] : (int($_[0])+ 1); }
sub floor {return int($_[0]);  }

sub format {
  my ($value,$fmt)=@_;
  $SCRIPT_RESULT.=sprintf('%.'.$fmt,$value);
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>