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

Symta is crazy and unreadable

Name: Anonymous 2022-11-18 22:34

Given a list L, take last 6 elements of that list, and remove the last of these 6 elements, returning the 5 elements in front. If the list has less than 6 elements or isn't even a list at all, return 42

In Symta that is solved with a simple expression:
L(42:@_ ~/5 _)
https://imgur.com/a/bBvr2n6


In your Pissthon/JustShit/LUserAss it is solved as...

Name: The Existor 2022-11-19 2:05

shut up Nikita Sadkov

Name: The Existor 2022-11-19 2:06

play my rook's gambit

Name: Anonymous 2022-11-19 4:45

Why would you ever want to do that?

Name: Anonymous 2022-11-19 8:21

>>4
programming interview challenge for pajeet job

Name: Anonymous 2022-11-19 9:05

>>4
Why would you want to take string "foo(bar1, bar2, ..., barN)" and quickly take barN out of it? I don't know...

Name: Anonymous 2022-11-19 9:24

Here is something funny you wont see in any language but REFAL and Symta:
https://imgur.com/a/FPDS4G5

Lisp dialect called MIT PLANNER also allowed for something similar, but the syntax was very inconvenient:
http://dspace.mit.edu/bitstream/handle/1721.1/5833/AIM-203.pdf?sequence=2&isAllowed=y
Scheme has `match` macro, but it is very limited and inconvenient compared to languages built around pattern matching.

Erlang too peeked a bit into the feed forward matchers, but they knew nothing about what they were doing and never went further than:
blah(true) ->
foo(),
bar();
blah(false) ->
baz().

Name: Anonymous 2022-11-19 12:50

blease stop using imgur to host source code

Name: Anonymous 2022-11-19 13:46

PLANNER style fact bottom up inference:
https://imgur.com/a/AL2nBKj

Guess you can try implementing it with a bunch of Perl regexps, but it will be a mess. In practice such inference is useful for video game pathfinding, when it involves more than just moving from point A to B, but involves transportation modes and tools, like rope or say potion of feather fall in a D&D game. So any remotely complicated video game will have it in one way or another. Yet Symta has it builtin.

I'm still unsure is there any reason to implement the top-down analytical inferences, since it is kinda similar, but I guess more natural for some tasks in video games.

Name: Anonymous 2022-11-19 22:29

Please explain symta syntax.

Name: Anonymous 2022-11-20 12:43

Name: Anonymous 2022-11-20 12:54

>>11
Protip: when someone asks you to explain something and you tell them that it's obvious and they're retarded, it's not a good look.

Name: Anonymous 2022-11-20 14:08

>>12
`@` was always a part of LISP https://stackoverflow.com/questions/21463925/meaning-of-at-sign-in-lisp

[bare words list] is a classic POP11 syntax for lists, and is frequently introduced into LIPS dialects

`_` is a also classic symbol from LISPs with pattern matching: https://blog.theincredibleholk.org/blog/2013/02/11/matching-patterns-with-scheme/

In pattern matchers `@` becomes a kleene star, which also binds the value. If `@` has no name, it is assumed to be @_

`~` is autoextractor, saves from typing and thinking about temporary variables names.

`$` servers a role of backtick, cuz I use `back ticks` for symbols, instead of the classic |symbol name|. Instead `|` is being used of a more useful thing.

`{}` - map operator. In the simplest form `Xs{X=Y}` acts as the usual LISP map, but due to pattern matching nature, it can also do stuff like `Pixels{R G B = B G R}` to swap color order, or [0:9]{?%2=} to strip odd integers

`(A=B;C=D,...,N=M)` is a transliteration operator

`(:...)` advanced form of the above, which has builtin y-combinator shortcut for quickly processing trees.

So Xs(~@) would be (car Xs) in usual LISP, Xs(_@~) would be (cdr Xs). But default these return `No` on failure but I can changer it into error Xs(bad 'pattern match failed':_@~), or return an empty list Xs([]:_@~). That saves immense amount of typing and screen space, because 50% of LISP code deals with lists that could have no car or no tail.

In fact, Symta doesn't have CAR and CDR, instead it has OOP subsystem, and lists expose head and tail methods. That way users can define their own list types, which will work with the pattern matcher machinery. For example, hash tables can be converted to lists of key-value pairs.

Name: Anonymous 2022-11-20 22:07

>>7
They probably knew, it is based on prolog after all.

Name: Anonymous 2022-11-20 22:27

>>14
Prolog wasn't about pattern matching, but about inverting the design methodology. In Prolog you go from goal to subgoals (top-down approach). But normally you go bottom-up (also called evolutionary, or constructive approach), from where you are to the goal, piling subroutines on top of each other till the get you to the goal. Although you can try starting with stubs, and then work you path all the way down to subgoals, usually it is done outside of the source code, in the design documents.

It is similar to pathfinding algorithms: you can start directly from the goal, or you can start from where you are and recursively enumerate possibilities till one of them corresponds to a goal. Yet going from the goal usually fails for most tasks. Consider chess AI, it works with so many paths, that practically it is impossible to go from the goal. So you go from where you are and pick the best move, which heuristically will move you closer towards the goal. Same with programming in general: you have fuzzy idea of a goal and do a lot of R&D along the way. Further more, many data-structures and tasks don't allow going top-down (i.e. finding a leaf in a tree, since you have to descend the tree anyway). That is why Prolog and top-down approaches fail in general.

Anyway, it has nothing to do with pattern matching, which stays the same no matter what approach you take. It is just that it could get inverted. I.e. think about parsers: you can parse your language bottom-up or top-down, but no matter what the syntax rules will stay the same.

Name: Anonymous 2022-11-21 1:30

shut up dikita sadkov

Name: Anonymous 2022-11-21 15:58

>>16
whom are you addressing, hitler?

Name: Anonymous 2022-11-21 20:19

Now given a list `L: [1 1 1] [2 3 4] [5 6]`
```
L: [1 1 1] [2 3 4] [5 6]
say L{_ ~ _} //says (1 3 (5 6))
say L{:_ ~ _} //says (1 3)
say L{[_ ~ _];[~ _]} //says (1 3 5)
say L{_ ~ ~} //says ((1 1) (3 4) (5 6))
```

Name: Anonymous 2022-11-21 23:28

return size(x,1)>6? x[end-5:end] : 42;

Name: Anonymous 2022-11-21 23:49

>>19
What C++ clone is that? Google Go?
What if x is not a list?
Where is `end` defined?

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