Using the Error Function

This commit is contained in:
2025-09-12 19:59:53 +10:00
parent e028cae397
commit aa882c10fb
2 changed files with 9 additions and 7 deletions

View File

@@ -62,7 +62,7 @@ fun -int !factorial -int &in
return $ans return $ans
@error @error
divide 1 0 &store error "Cannot find factorial of a negative integer"
endfun endfun
fun -double !cos -double &in fun -double !cos -double &in
@@ -206,4 +206,8 @@ fun -double !sqrt -double &in
return $ans return $ans
@error @error
error "Cannot find square root of a negative double"
endfun endfun
pusharg -0.5
call !sqrt &store

View File

@@ -46,14 +46,11 @@ endfun
fun -string !mid -string &str -int &idx -int &len fun -string !mid -string &str -int &idx -int &len
set &ans "" set &ans ""
lesser $idx 0 &store lesser $idx 0 &store
if $store %end if $store %negend
greater $len 0 &store greater $len 0 &store
if $store %loop if $store %loop
return "" return ""
@loop @loop
getstrsize $str &store
equal $store $idx &store
if $store %end
getstrcharat $str $idx &store getstrcharat $str $idx &store
add $ans $store &ans add $ans $store &ans
add $idx 1 &idx add $idx 1 &idx
@@ -65,7 +62,8 @@ fun -string !mid -string &str -int &idx -int &len
@return @return
return $ans return $ans
@end @negend
error "Cannot start mid at a negative index"
endfun endfun
fun -string !inBrackets -string &str -char &left -char &right -int &instance fun -string !inBrackets -string &str -char &left -char &right -int &instance