Bruno Medeiros:
>* Having non-unicode versions of the symbols/keywords available in Unicode, 
>such that non-Uunicode editing and viewing is always possible as a fallback. 
>This has some important consequences though, such as making 
>Unicode-symbol-usage unable to solve the shortage of brackets for, for 
>example, the template instantiation syntax (because an alternative ASCII 
>notation would still be necessary).<

Fortress uses pairs of symbols to denote various sequence literarls. Some of 
them can be seen in F# too, you can see some here:
http://a6systems.com/fsharpsheet.pdf

Creates the list:
let lsgen2 = [0 .. 2 .. 8]
Gives:
[0;2;4;6;8]
Note:  0 .. 2 .. 8  equals to the Python slice with stride syntax 0:8:2

Create the array:
let argen2 = [|0 .. 2 .. 8|]
Gives:
[|0;2;4;6;8|]

Creating a seq (that is lazy):
let s = seq { for i in 0 .. 10 do yield i }  


F# has also algebraic types that will become very useful in D2, as it becomes 
more functional (as them are useful in Scala too, that is partially functional. 
F# and Scala are languages to copy from because they are 
functional-procedural-OOP hybrids almost like D2 will want to become, D2 is so 
far just a bit functional, Scala is more functional, F# even more, and 
languages like Haskell are functional all the way), this is an Augmented 
Discriminated Union:

type BinTree<'a> =
    | Node of
        BinTree<'a> * 'a *
        BinTree<'a>
    | Leaf
  with member self.Depth() =
        match self with
        | Leaf -> 0
        | Node(l, _, r) -> 1 +
            l.Depth() + r.Depth()

So D2 can use collection literals similar to those ones in F# to implement 
lazy/nonlazy collection generators too, this is the third iteration of my ideas 
on this topic (if you think succintness in (partially) functional languages is 
useless, think again. It allows to use certain things instead of falling back 
to more procedural idioms):

auto flat = (abs(el) for(row: mat) for(el: row) if (el % 2)); // lazy
auto multi = [c:mulIter(c, i) for(i,c: "abcdef")]; // AA
auto squares = void[x*x for(x: 0..100)]; // set
void[int] squares = [x*x for(x: 0..100)];// set, alternative syntax
auto squares = {x*x for x in xrange(100)}; // set, alternative syntax
auto squares = {| x*x for(x: 0..100) |}; // list?
auto squares = [| x*x for(x: 0..100) |]; // multiset? something else?

Bye,
bearophile

Reply via email to