samarium-lang/Samarium

Add `io.inputcast`

Closed this issue · 0 comments

⚠️ Make sure you're contributing to the 0.4.0 branch!

This function should work just like ???, but it should try to convert inputs to specific types:

  • "1"/
  • "1 2"[/, /\]
  • "3, 4"[//, /\\]
  • "" ‎ ‎ (NULL)
  • "3..7"<<//..///>>
  • "a=1, b=2"{{"a" -> /, "b" -> /\}}
  • "hi""hi"
<-io.inputcast;

=> * {
    inputcast("Enter a number to double: ") ++ /\!;
}
Enter a number to double: 7
14

The prompt should be optional ("" by default).