Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Symta v0.2

Name: Anonymous 2012-12-08 11:36

Ok. I put out the second release of Symta: http://sym.at.ua/load

Also the SymCraft/LispCraft sources are under 1100 lines (http://sym.at.ua/photo), including UI and a simple AI.

Name: Anonymous 2012-12-10 3:16

hey op, i thought you boner

Name: Anonymous 2012-12-10 5:12

>>80
That is why I use CL.

Name: Anonymous 2012-12-10 17:25

u were banned for a good reason op. stop your math sacrilege.

Name: Anonymous 2012-12-10 17:27

And how many lines would it take to write the C equivalent of your buggy, incomplete Warcraft II ?

Name: Anonymous 2012-12-10 18:16

>>84
Probably quite a few less. Lisp is known to be rather terse.

Name: Anonymous 2012-12-10 18:24

>>85
I meant more. More C lines.

Name: Anonymous 2012-12-10 19:27

U.owner≥≤ThisPlayer
Get a job, Ahmed!

Name: Anonymous 2012-12-11 14:11

>>84
I once wrote random map generator for Warcraft II and it took 1600 lines (http://sym.at.ua/load/wc2mapgen/1-1-0-10)

Name: Anonymous 2012-12-11 14:16

Dear Ahmed,

Symta can go a long way if you provide tutorials and a more complete documentation.

Name: Anonymous 2012-12-11 14:59

>>7
Everyone uses C in the end.

Let's face it, while other systems may be construed as being perfect, C is the only thing that really works.

Name: Anonymous 2012-12-11 15:08

>>90
ADA motherfucker, do you speak it?

Name: Anonymous 2012-12-11 17:43

>>89
I'll try to rewrite Arc tutorial for this purpose...


[This is a brief tutorial on Symta.  It's intended for readers with
some Lisp experience.]


Symta programs consist of expressions.  The simplest expressions are
things like numbers and strings, which evaluate to themselves.

-> 25
25
-> “foo”
“foo”
-> ~123  // negative number
~123

Note the unicode “” (U+201C and U+201D) quotes, which can be easily
nested. For convenience we also support usual "" ASCII-quotes.

Several expressions enclosed within parentheses are also an expression.
These are called lists.  When a list is evaluated, the elements are
evaluated from left to right, and the value of the first (presumably
a function) is passed the values of the rest.  Whatever it returns
is returned as the value of the expression.

-> `+` 1 2
3

Here's what just happened.  First `+`, 1, and 2 were evaluated,
returning the plus function, 1, and 2 respectively.  1 and 2 were
then passed to the plus function, which returned 3, which was
returned as the value of the whole expression.  `` quotes allow
us to use any string (even ()-braces) as a function/variable name.

(Macros introduce a twist, because they transform lists before
they're evaluated.  We'll get to them later.)

Since expression and evaluation are both defined recursively,
programs can be as complex as you want:

-> `+` (`+` 1 2) (`+` 3 (`+` 4 5))
15

Putting the `+` before the numbers looks odd when you're used to
writing "1 + 2," but Symta, in contrast to other Lisps, supports
infix sugar, which automatically transforms expressions into
their prefix form:

-> 1+2+3+4+5
15

This turns out to be a convenient feature, and doesn't impede
generating code that much, which is a common thing to do in Lisp.

Also, in contrast to other Lisp dialects, Symta doesn't discern
between strings and symbols. We've already seen one: `+` which is
just an unquoted “+” string, being treated as code. Unquoted strings
don't evaluate to themselves the way numbers and “”-strings do.
They return whatever value they've been assigned.

If we give Foo the value 13, it will return 13 when evaluated:

-> Foo = 13
13
-> Foo
13

Note that all variables must start from uppercase letter, which
functions can start from any non-uppercase character. Such
notation improves readability and frees non-uppercase symbols
for special use.

You can turn off evaluation by putting the \ slash character
before an expression.  So \Foo returns the symbol Foo.

-> \Foo
Foo


If you quote a list, you get back the list itself. 

-> (`+` 1 2)
3
-> \(`+` 1 2)
(`+` 1 2)

-> `\\` 1+2   // note how we escape \ slash to use it inside string
(`+` 1 2)

The first expression returns the number 3.  The second, because it
was quoted, returns a list consisting of the symbol + and the numbers
1 and 2. The third expression show how to escape infix expressions.

You can build up lists with [] and @
-> [1 2]
(1 2)

-> [\f @\(a b)]
(f a b)

-> [1 @[2 3] 4 @[5 6] 7]
(1 2 3 4 5 6 7)

-> l 1 @[2 3] 4 @[5 6] 7
(1 2 3 4 5 6 7)

-> `[]` (1 @[2 3] 4 @[5 6] 7)
(1 2 3 4 5 6 7)

As you can see operator `@` does an interpolation inside `[]`,
while `l` is used when you want to avoid braces. Last line shows
that `[]` is in fact a "macro", which doesn't eval it's arguments,
but transforms them into a number of calls to low-level `conc`,
`pre`, `suf` and functions (similar to CONS from Common Lisp),
which would be too error prone to use directly.


While by default interpolating operator `@` doesn't change the
original list, with `!` it can be made easily used to do so:

-> Yoba = \(a b)
(a b)
-> [\f @Yoba]
(f a b)
-> Yoba
(a b)

-> [\f @!Yoba]
(f a b)
-> Yoba
(f a b)

In general, any variable prefixed by `!` takes value of resulting
expression. If you are used to C/C++, you can easily simulate `++`
and `--`, with `!`:

-> Yoba = 123
123
-> !Yoba+1
124
-> Yoba
124
-> !!Yoba+1
124
-> Yoba
125

While `!!` too sets Yoba to the new value, it returns previous one,
acting like postfix `++` from C/C++.


The empty list is represented by the symbol ø, which is defined
to evaluate to itself. For the same purpose we can use just ()

You can take lists apart with lhd, ltl, rhd and ltl functions, which
return the head element and tailing elements relatively to the beginning
and to the end of a list respectively:

-> lhd \(a b c)
a
-> ltl \(a b c)
(b c)
-> rhd \(a b c)
c
-> rtl \(a b c)
(a b)

Another operator `,` picks element by it's numeric position in list:
-> [1 2 3],0
1
-> [1 2 3],(~1) // when index is negative, takes from the end
3

function `t` and `d` take and drop number of elements from a list:
-> t 3 [1 2 3 4 5 6 7]
(1 2 3)
-> t ~3 [1 2 3 4 5 6 7]
(5 6 7)
-> d 3 [1 2 3 4 5 6 7]
(4 5 6 7)
-> d ~3 [1 2 3 4 5 6 7]
(1 2 3 4)

Generic Symta lists must guarantee reasonably fast O(log2(N)) random
access and concatenation. This may not apply to lists, optimized for
specific purpose like arrays or hash-tables.

Name: Anonymous 2012-12-11 17:46

>>90
Because crappy Unix is written in C/C++, so we are forced to work with it.

Name: Anonymous 2012-12-11 17:47

>>90 is true.

Name: Anonymous 2012-12-11 18:08

>>92

1+2+3+4+5 -> (+ 1 (+ 2 (+ 3 (+ 4 5)))) ?

[1 2 3],4 is just an error?

Name: Anonymous 2012-12-11 18:12

>>95
Thanks.
[1 2 3],4 is just nil

Name: Anonymous 2012-12-11 18:13

>>95

-> `\\` 1+2+3+4+5
(`+` (`+` (`+` (`+` 1 2) 3) 4) 5)

Name: Anonymous 2012-12-11 20:37

symta confirmed for legitimate.

Name: Anonymous 2012-12-11 21:06

I have to get 99get in the Symta thread.

Name: Anonymous 2012-12-11 21:21

>>98
Only if you consider legitimate as being ugly as Haskell.

Name: Anonymous 2012-12-11 21:25

this thread is symtarded.

Name: Anonymous 2012-12-11 22:18

Can Symta do this?
http://cur.lv/buva

Name: Anonymous 2012-12-11 22:41

cur.lv
What the fuck, nigger anus?

Name: Anonymous 2012-12-11 22:45

>>103
Short URL service.

Name: Anonymous 2012-12-11 23:27

>>104
Yeah keep spreading lies kike fagshit

Name: Anonymous 2012-12-11 23:48

>>102-105
I guess not.
Symta confirmed for less useful than Haskell.

Name: Anonymous 2012-12-12 5:30

Can Symta do this?
http://cul.vr/buva

Name: Anonymous 2012-12-12 6:59

>>107
Pow, right in the Symta!

Name: Anonymous 2012-12-12 8:13

>>108
Right in the Culver.

Name: Anonymous 2012-12-12 8:22

>>102
That redirects to
http://systemofwinning.weebly.com/
hi my name is ahmed and i like playing casinos games before many years ago and testing many casinos and i created many systems and strategies and really some of its work well and some not work but finally and after hard work i succeeded to make some strategies to make u earn more u lose and be happy to make money as 100$ every day ,now i will learn u one of my strategies and remember i give u it 100% free nothing to pay me as many sites who scam u and take yr money k now lets start explain   :-
first my system is about playing roulette u must know it . its as a game of casino and it is be in any casino online k but our system is working  well in this casino

Name: Anonymous 2012-12-12 9:51

>>102,107
You're not Ahmed, you avaricious kike.

Name: Anonymous 2012-12-12 10:02

>>110
hi my name is ahmed
IHBT

Name: Anonymous 2012-12-12 12:35

>>110
Lies! I was expecting some Ahmed, but instead I just got a pastebin full of dead dog!

Name: Anonymous 2012-12-13 11:12

>>92

Like Common Lisp assignment, Symta's `=` is not just for variables,
but can reach inside structures.  So you can use it to modify
associative lists or array indices:

-> = X:ø = (X.abc.def = 123) = X
((abc ((def 123))))

-> = X:[1 2 3] = (X,1 = 123) = X

Note that `=` is non-destructive, because it creates a new list on
each use, instead of modifying underlaying structure.

Lists are useful in exploratory programming because they're so
flexible.  You don't have to commit in advance to exactly what a
list represents.  For example, you can use a list of two numbers
to represent a point on a plane.  Some would think it more proper
to define a point object with two fields, x and y.  But if you use
lists to represent points, then when you expand your program to
deal with n dimensions, all you have to do is make the new code
default to zero for missing coordinates, and any remaining planar
code will continue to work.

Or if you decide to expand in another direction and allow partially
evaluated points, you can start using symbols representing variables
as components of points, and once again, all the existing code will
continue to work.

In exploratory programming, it's as important to avoid premature
specification as premature optimization.

The most exciting thing lists can represent is code.  The lists you
build with [] and \() are the same things programs are made out of.
This means you can write programs that write programs. The usual
way to do this is with something called a macro.  We'll get to those
later.  First, functions.

We've already seen some functions: `+`, lhd, ltl, and t.  You can
define new ones with `=`, which takes a symbol to use as the name,
a list of expressions representing the parameters, and then zero or
more `=` prefixed expressions called the body.  When the function
is called, those expressions will be evaluated in order with the
symbols in the body temporarily set ("bound") to the corresponding
parameters. Whatever the last expression returns will be returned as
the value of the call.

Here's a function that takes two numbers and returns their average:

-> average X Y = (X+Y)/2
$(fn Name:average Adr:#x1002DB0EEB)
-> average 2 4
3

The body of the function consists of one expression, "= (X+Y)/2".
It's common for functions to consist of one expression; in purely
functional code (code with no side-effects) they always do.

Notice that without `=`, `average X Y` would be just a function call.

What's the strange-looking object returned as the value after defintion
expression?  That's what a function looks like.  In Symta, as in most
Lisps, functions are a data type, just like numbers or strings.

As the literal representation of a string is a series of substrings
surrounded by double quotes, the literal representation of a function
is a list enclose inside `<>` braces.  So you could represent an
unnamed (anonymous) function to return the average of two numbers as:

-> <X Y = (X+Y)/2>
$(fn Name:r Adr:#x1002E4432B)

There's nothing semantically special about named functions as there
is in some other languages.  All `average X Y = (X+Y)/2` just assigns
<X Y = (X+Y)/2> to the symbol `average`.

And of course you can use a literal function wherever you could use
a symbol whose value is one, e.g.

-> <X Y = (X+Y)/2> 2 4
3

This expression has three elements, <X Y = (X+Y)/2>, which
yields a function that returns averages, and the numbers 2 and 4.
So when you evaluate all three expressions and pass the values of
the second and third to the value of the first, you pass 2 and 4
to a function that returns averages, and the result is 3.

Careful reader should note, that we omit parentheses around top-level
expressions. This notation has it tradeoffs, because now we have to
explicitly call any function, which takes no arguments. We use `c`
function for this:

-> <= 1 + 2>
$(fn Name:r Adr:#x100311C1BB)
-> c <= 1 + 2>
3
-> c <X = 1 + 2 + X> 4
7

As you can see, `c` can also call a function, which does take arguments.
Basically, `c` is analogous to funcall in Common Lisp.

There's one thing you can't do with functions that you can do with
data types like symbols and strings: you can't print them out in a
way that could be read back in.  The reason is that the function
could be a closure; displaying closures is a tricky problem.

In Symta, functions can also parse its arguments, akin to BNF. So
we can destructure list with them or just do pattern matching:

-> <[X Y] = (X+Y)/2> [2 4]
3
-> <[X Y] = (X+Y)/2> [2 4 6]
ø
-> <[X:even? Y] = (X+Y)/2> [2 4]
3
-> <[X:even? Y] = (X+Y)/2> [3 4]
ø

Note how <[X Y] = (X+Y)/2> returns ø (nil or false), when argument
doesn't match pattern. Many would consider such default unsafe, but
it greatly reduces code size. [X:even? Y] matches only pairs with
even first element: `even?` is just a predicate function. Symta's
predicates are usual functions, but have semantics of returning their
arguments, when it matches condition, or ø. For convenience predicate
names end with `?`. `X:even?` binds result of `even?` to X, or
returns ø, when `even?` returns ø.

The operator `:` can also be used for establishing temporary
variables, when used after `=`:

-> <X Y = Z:X+Y = Z/2> 2 4
3
-> = X:2 = X+X*2
6
-> = X:3 = Y:4 = sqrt X^2 + Y^2
5.0

operator `^` does exponentiation.

So far we've only had things printed out implicity as a result of
evaluating them.  The standard way to print things out in the middle
of evaluation is with `p` or `say`. The difference is that `p` does
pretty printing and returns it's argument, while `say` returns ø.
`p` is useful for debugging, as you can easily insert `p` between
function calls:

-> <X Y = (X+Y),p/2> 2 4
6
3

-> average X Y = say “my arguments were: $X $Y” = (X+Y)/2
$(fn Name:average Adr:#x1004DCA31B)
-> average 100 200
my arguments were: 100 200
150

For the first time we used `,` operator in it's other role - applying
function to an argument:
-> 3,<X=X*2>,<X=X/5>
6/5

The standard conditional operator is {}. It acts both as if and
cond/switch statement:
-> {odd? 1 = \a; \b}
a
-> {odd? 2 = \a; \b}
b
-> yoba A B = {A≤B = “A<B”
              ;A≥B = “A>B”
              ; √  = “A=B”}
$(fn Name:yoba Adr:#x10033CA54B)
-> yoba 7 4
`A>B`
-> yoba 2 4
`A<B`

When `=` is missing it {} just return the first true value:
-> {even? 3; odd? 7; 123}
7
-> {even? 3; odd? 8; 123}
123

Name: Anonymous 2012-12-13 11:13

>>114
Returning true means returning anything except ø. ø is
conventionally used to represent falsity as well as the empty list.
The symbol √ (which like ø evaluates to itself) is often used to
represent truth, but any value other than ø would serve just as
well.

-> (odd? 1)

-> (odd? 2)
ø

If the √ case is missing it defaults to nil.

-> {odd? 2 = \a}
ø

Just like <>, you can use {} with multiples `=`:

-> {odd? 3 = say “hi!” = say “3 is odd” = “bye”}
hi!
3 is odd
bye

Besides {}, we also have `a` and `v` macros, which stand for logical
and and or. They are intended to use in pipes:

-> {odd? 3 |a 3≥0 = “3 is odd and positive”}
3 is odd and positive
-> {odd? ~3 |a ~3≥0 = “3 is odd and positive”}
ø
-> {odd? ~3 |v ~3≥0 = “~3 is either odd or positive”}
3 is either odd or positive

Here `|` is a pipe, which takes argument 3 to the left and calls
`a` with it, like `a 3≥0 (odd? 3)`. `a` is just a macro, expanding
into {3≥0 = odd? 3}. Later we will review pipes and macros in detail.

The negation operator is called `n`.  Here's a function to return
the length of a list:

-> mylen Xs = {n Xs = 0; 1+(mylen (ltl Xs))}
$(fn Name:mylen Adr:#x100455EADB)

If the list is ø the function will immediately return 0.  Otherwise
it returns 1 more than the length of the left tail of the list.

-> mylen ø
0
-> mylen \(a b)
2

I called it mylen because there's already a function called len for
this. You're welcome to redefine Symta's functions, but redefining
len this way will break code that depended on it.

The standard comparison operator is ≥≤, which returns √ if its
arguments are identical or, if strings, have the same characters.

-> 123 ≥≤ 123

-> \foo ≥≤ \foo

-> = X:[\foo 123] = X ≥≤ X

-> [\foo 123] ≥≤ [\foo 123]


There is also ptrEq function, which compares objects by their
pointers:

-> = X:[\foo 123] = X ≥≤ X

-> ptrEq [\foo 123] [\foo 123]
ø

If you want to test whether something is one of several alternatives,
you could say {X≥≤Y; X≥≤Z; ...}, but that would be a little verbose.
We use our function pattern matching for this:
-> = X:\b = X,<\a;\b;\c>


-> translate \apple=\mela; \onion=\cipolla; X=\che?
$(fn Name:translate Adr:#x100A79691B)
-> translate \onion
cipolla
-> translate \syzygy
che?

Yes. Function `translate` has several cases, and each case has its
own body.

Symta has a few generating and iterating utilities. To generate a
sequence of numbers, use `rng`
-> rng 10
(0 1 2 3 4 5 6 7 8 9)

-> rng 7 20
(7 8 9 10 11 12 13 14 15 16 17 18 19)

-> rng 7 3 20 // uses step 3
(7 10 13 16 19 22 25 28 31 34 37 40 43)

To iterate through the elements of a list, use `e`.
-> rng 10 | e <X = say “$X ” nl:ø>
0 1 2 3 4 5 6 7 8 9 ø

That was another example of using `|` and also and example of
passing to `say` the keyword `nl`, which forbids say to print
newlines. As always operators `|` translates `rng 10 | e F`
into `e F (rng 10)`. Alternatively you can write `e F :: rng 10`

-> e <X = say “$X ” nl:ø> :: rng 10
0 1 2 3 4 5 6 7 8 9 ø

To filter elements from list, use `k` (keep) and `s` (skip). `k`
removes element for which it's predicate returns ø, `s` does the
opposite:

-> rng 7 20 | k odd?
(7 9 11 13 15 17 19)

-> rng 7 20 | s odd?
(8 10 12 14 16 18)

To continue iterating while some condition is true, use while.

-> = X:10 = while X≥5 (= !X-1 = say X nl:ø)
98765ø

There's also a more general for-operator that's similar to the C
for operator and tends to be rarely used in practice, and a simple
repeat operator `times` for doing something n times:

-> times 5 say “la ” nl:ø
la la la la la ø

The `m` (map) function takes a function and a list and returns the
result of applying the function to successive elements.

-> m <X+X+10> [1 2 3]
(11 12 13)

Actually `m` can take any number of sequences, and keeps going till
the shortest runs out:

-> m `+` \(1 2 3 4) \(100 200 300)
(101 202 303)

Since functions of one or twow argument are so often used in Lisp
programs, Symta has a special notation for them.  `... ? ...` is an
abbreviation for <X = ... X ...>, where X stands for a uniq symbol.
So our first map example could have been written

-> m ?+10 [1 2 3]
(11 12 13)

Here `?+10` produces expression equivalent to <X+X+10>. Beside ?,
we can have ?? and ???:
-> (?+??)/??? 2 4 2  // cal average of 2 and 4
3

We can compose functions by using `?`. I.e. `?,bar,foo` is equivalent
to <X = foo (bar X)>. Composed functions are convenient as arguments.

-> k ?,lhd,odd? \((1 2) (4 5) (7 9))
((1 2) (7 9))

We can also easily negate a function:

-> k ?,odd?,n \(1 2 3 4 5)
(2 4)

Name: Anonymous 2012-12-13 11:16

Hope Paul Graham wont kill me for stealing and modifying his tutorial. I'm just too lazy to make my own.

Name: Anonymous 2012-12-13 11:18

Ahmed is documenting Symta!

I LOVE YOU AHMED! PLEASE POST MORE!

Name: Anonymous 2012-12-13 11:21

I'd try Symta but I'm too lazy

Name: Anonymous 2012-12-13 11:43

It would be nice to have a single non-latin symbol for each of these common functions.

Name: Anonymous 2012-12-13 13:44

>>119
Well, these one-letter functions do consume namespace, but most one-letter variables are uppercase anyway. Good idea would be forbidding redefining them. On the other hand, Emacs makes most unicode symbols look terrible and other editors don't support unicode input at all.

I already use ≤≥, because <> are used as lambda, and still consider using usual eq/lt/gt.. instead.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List