Skip to content

Tutorial: Types: ERR TRY

molarmanful edited this page Nov 25, 2023 · 7 revisions

ERR

ERR is sclin's error type. It encapsulate 2 strings: one denoting type and another denoting message.

All ERRs are falsy.

"TYPE""error message">E

TRY

TRY represents a computation that may succeed or fail.

Failed TRYs are falsy; successful TRYs are truthy.

"success">!?
"FAIL""failed">E >!?

"success">!+
"failed">!-

( 2 1/ )!
( 1 0/ )!

You can use functions like map, mapf, fltr, each to manipulate the contents of the TRY.

"try"@# [.
  () ( "success"n>o ) ,.
  () ( "fail"n>o ) ,.
]: ??#

#try.
  ( "1">N )! ( =$a. ) mapf
  ( "0">N )! ( =$b. ) mapf
  ( $a $b / )!