h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
310 stars 23 forks source link

range #115

Closed ghost closed 3 years ago

ghost commented 3 years ago

range symbol isn't working with float and char value included quote:

(1.5 3.5) range ;; expected a quot is (1.5 2.5 3.5) instead of an error
("a" "c") range ;; expected a quot is ("a" "b" "c") instead of an error

Erorr:

(!) <repl>(1,19) [range]: 'intVal' is not accessible using discriminant 'kind' of type 'MinValueObject'
    <repl>(1,19) in symbol: range
h3rald commented 3 years ago

Going to fix it for num but strings... mmmm, don't wanna get into that for now (no Unicode support yet etc)

ghost commented 3 years ago

Going to fix it for num but strings... mmmm, don't wanna get into that for now (no Unicode support yet etc)

Maybe for ASCII?

h3rald commented 3 years ago

๐Ÿค”๐Ÿคจ๐Ÿคฌ hmmmmmm....

Problem is that it would have to be extended quite a bit to support all that validation, and it's in the num module... OR! You could just use ord and chr with a sprinkle of apply and map and be done with it:

("a" ord "z" ord) => range 'chr map

๐Ÿ˜ฌ๐Ÿ‘๐Ÿ‘๐Ÿ˜Ž

Erhm... in the same spirit, you could just use it as-is and map it to whatever float you want to get a range of floats:

 (1 7) range (0.5 *) map

So, in other words, I gotta fix only the validation and make sure you can provide only a quotation of int values. ๐Ÿ˜Š

ghost commented 3 years ago

(1 7) range (0.5 *) map

Not a great solution i think. โŒ ๐Ÿ˜ธ Result quote doesn't even start from 1 right?? : (0.5 1.0 1.5 2.0 2.5 3.0 3.5)

But as you mean, one never need to a native float or string range. Instead, one need to be wise for thinking how will symbols which are much more useful done in min... haha

Thanks for enlighting me. ๐Ÿ’ก

h3rald commented 3 years ago

Haha yes you are right, didn't think of that with floats ๐Ÿ˜Š๐Ÿ‘

But yes we can survive without.

ghost commented 3 years ago

But yes we can survive without.

Yep, right!

h3rald commented 3 years ago

Fixed in v0.31.0.