CAPA Functions
| LON-CAPA
| Differences (if any)
|
sin(x), cos(x), tan(x) | &sin($x), &cos($x), &tan($x) | |
asin(x), acos(x), atan(x), atan2(y,x) | &asin($x), &acos($x), &atan($x), &atan2($y,$x) | |
log(x), log10(x) | &log($x), &log10($x) | |
exp(x), pow(x,y), sqrt(x) | &exp($x), &pow($x,$y), &sqrt($x) | |
abs(x), sgn(x) | &abs($x), &sgn($x) | |
erf(x), erfc(x) | &erf($x), &erfc($x) | |
ceil(x), floor(x) | &ceil($x), &floor($x) | |
min(...), max(...) | &min(...), &max(...) | |
factorial(n) | &factorial($n) | |
N%M | $N%$M | |
sinh(x), cosh(x), tanh(x) | &sinh($x), &cosh($x), &tanh($x) | |
asinh(x), acosh(x), atanh(x) | &asinh($x), &acosh($x), &atanh($x) | |
/DIS($x,"nn") | &format($x,'nn') | The difference is obvious. |
Not in CAPA | &prettyprint($x,'nn','optional target') | |
Not in CAPA | &dollarformat($x,'optional target') | |
Not in CAPA | &languages(@desired_languages) | |
roundto(x,n) | &roundto($x,$n) | |
Not in CAPA | &cas($s,$e) | |
Not in CAPA | &implicit_multiplication($f) | |
web("a","b","c") or web(a,b,c) | &web("a","b","c") or &web($a,$b,$c) | |
html("a") or html(a) | &html("a") or &html($a) | |
jn(m,x) | &j0($x), &j1($x), &jn($m,$x), &jv($y,$x) | In CAPA, j0, j1 and jn are contained in one function, jn(m,x) where m takes the value of 0, 1 or 2. jv(y,x) is new to LON-CAPA. |
yn(m,x) | &y0($x), &y1($x), &yn($m,$x), &yv($y,$x) | In CAPA, y0, y1 and yn are contained in one function, yn(m,x) where m takes the value of 0, 1 or 2. yv(y,x) is new to LON-CAPA. |
random(l,u,d) | &random($l,$u,$d) | In CAPA, all the 3 arguments must be of the same type. However, now you can mix the type |
choose(i,...) | &choose($i,...) | |
/MAP(seed;w,x,y,z;a,b,c,d) |
Option 1 - &map($seed,[\$w,\$x,\$y,\$z],[$a,$b,$c,$d]) or |
Option 2 - &map($seed,\@mappedArray,[$a,$b,$c,$d]) |
Option 3 - @mappedArray = &map($seed,[$a,$b,$c,$d]) |
Option 4 - ($w,$x,$y,$z) = &map($seed,\@a) |
where $a='A' |
$b='B' |
$c='B' |
$d='B' |
$w, $x, $y, and $z are variables |
| In CAPA, the arguments are divided into three groups separated by a semicolon ;. In LON-CAPA, the separation is done by using [] brackets or using an array @a. Note the backslash (\) before the arguments in the second and third groups. |
rmap(seed;a,b,c,d;w,x,y,z) |
Option 1 - &rmap($seed,[\$w,\$x,\$y,\$z],[$a,$b,$c,$d]) or |
Option 2 - &rmap($seed,\@rmappedArray,[$a,$b,$c,$d]) |
Option 3 - @rmapped_array = &rmap($seed,[$a,$b,$c,$d]) |
Option 4 - ($w,$x,$y,$z) = &rmap($seed,\@a) |
where $a='A' |
$b='B' |
$c='B' |
$d='B' |
$w, $x, $y, and $z are variables |
| In CAPA, the arguments are divided into three groups separated by a semicolon ;. In LON-CAPA, the separation is done by using [] brackets (with create an unamed vector reference) or using an array @a. Note the backslash (\) before the arguments in the second and third groups (Which cause Perl to send to variable locations rather than the variable values, similar to a C pointer). |
NOT IMPLEMENTED IN CAPA | $a=&xmlparse($string) | New to LON-CAPA |
tex(a,b), tex("a","b") | &tex($a,$b), &tex("a","b") | |
var_in_tex(a) | &var_in_tex($a) | |
to_string(x), to_string(x,y) | &to_string($x), &to_string($x,$y) | |
capa_id(), class(), section(), set(), problem() | &class(), &sec() | capa_id(), set() and problem() are no longer used. Currently, they return a null value. |
name(), student_number() | &name(), &student_number() | |
open_date(), due_date(), answer_date() | &open_date(), &due_date(), &answer_date() | Output format for time is changed slightly. If pass noon, it displays ..pm else it displays ..am. So 23:59 is displayed as 11:59 pm. |
get_seed(), set_seed() | Not implemented | |
sub_string(a,b,c) | &sub_string($a,$b,$c)
perl substr function. However, note the differences | Perl intrinsic function, substr(string,b,c) starts counting from 0 (as opposed to 1). In the example to the left, substr($a,4,4) returns "ome ". |
array[xx] | @arrayname
Array is intrinsic in perl. To access a specific element use $arrayname[$n] where $n is the $n+1 element since the array count starts from 0 | In LON-CAPA, an array is defined by @arrayname. It is not necessary to specify the dimension of the array. |
array_moments(B,A) | @B=&array_moments(@A) | In CAPA, the moments are passed as an array in the first argument whereas in LON-CAPA, the array containing the moments are set equal to the function. |
array_max(Name), array_min(Name) | &min(@Name), &max(@Name) | Combined with the min and max functions defined earlier. |
init_array(Name) | undef @name | Use perl intrinsic undef function. |
random_normal (return_array,item_cnt,seed,av,std_dev) | @return_array=&random_normal ($item_cnt,$seed,$av,$std_dev) | In CAPA the results are passed as the first argument whereas in LON-CAPA the results are set equal to the function. |
random_beta (return_array,item_cnt,seed,aa,bb) | @return_array=&random_beta ($item_cnt,$seed,$aa,$bb)
NOTE: Both $aa and $bb MUST be greater than 1.0E-37. | In CAPA the results are passed as the first argument whereas in LON-CAPA the results are set equal to the function. |
random_gamma (return_array,item_cnt,seed,a,r) | @return_array=&random_gamma ($item_cnt,$seed,$a,$r)
NOTE: Both $a and $r MUST be positive. | In CAPA the results are passed as the first argument whereas in LON-CAPA the results are set equal to the function. |
random_exponential (return_array,item_cnt,seed,av) | @return_array=&random_exponential ($item_cnt,$seed,$av)
NOTE: $av MUST be non-negative. | In CAPA the results are passed as the first argument whereas in LON-CAPA the results are set equal to the function. |
random_poisson (return_array,item_cnt,seed,mu) | @return_array=&random_poisson ($item_cnt,$seed,$mu)
NOTE: $mu MUST be non-negative. | In CAPA the results are passed as the first argument whereas in LON-CAPA the results are set equal to the function. |
random_chi (return_array,item_cnt,seed,df) | @return_array=&random_chi ($item_cnt,$seed,$df)
NOTE: $df MUST be positive. | In CAPA the results are passed as the first argument whereas in LON-CAPA the results are set equal to the function. |
random_noncentral_chi (return_array,item_cnt,seed,df,nonc) | @return_array=&random_noncentral_chi ($item_cnt,$seed,$df,$nonc)
NOTE: $df MUST be at least 1 and $nonc MUST be non-negative. | In CAPA the results are passed as the first argument whereas in LON-CAPA the results are set equal to the function. |
NOT IMPLEMENTED IN CAPA | @return_array=&random_f ($item_cnt,$seed,$dfn,$dfd)
NOTE: Both $dfn and $dfd MUST be positive. | New to LON-CAPA |
NOT IMPLEMENTED IN CAPA | @return_array=&random_noncentral_f ($item_cnt,$seed,$dfn,$dfd,$nonc)
NOTE: $dfn must be at least 1, $dfd MUST be positive, and $nonc must be non-negative. | New to LON-CAPA |
NOT DOCUMENTED IN CAPA | @return_array=&random_multivariate_normal ($item_cnt,$seed,\@mean,\@covar)
NOTE: @mean should be of length p array of real numbers. @covar should be a length p array of references to length p arrays of real numbers (i.e. a p by p matrix. | Note the backslash before the @mean and @covar arrays. |
NOT IMPLEMENTED IN CAPA | @return_array=&random_multinomial ($item_cnt,$seed,@p)
NOTE: $item_cnt is rounded with int() and the result must be non-negative. The number of elements in @p must be at least 2. | New to LON-CAPA |
NOT IMPLEMENTED IN CAPA | @return_array=&random_permutation ($seed,@array) | New to LON-CAPA |
NOT IMPLEMENTED IN CAPA | @return_array=&random_uniform ($item_cnt,$seed,$low,$high)
NOTE: $low must be less than or equal to $high. | New to LON-CAPA |
NOT IMPLEMENTED IN CAPA | @return_array=&random_uniform_integer ($item_cnt,$seed,$low,$high)
NOTE: $low and $high are both passed through int(). $low must be less than or equal to $high. | New to LON-CAPA |
NOT IMPLEMENTED IN CAPA | @return_array=&random_binomial ($item_cnt,$seed,$nt,$p)
NOTE: $nt is rounded using int() and the result must be non-negative. $p must be between 0 and 1 inclusive. | New to LON-CAPA |
NOT IMPLEMENTED IN CAPA | @return_array=&random_negative_binomial ($item_cnt,$seed,$ne,$p)
NOTE: $ne is rounded using int() and the result must be positive. $p must be between 0 and 1 exclusive. | New to LON-CAPA |
|