Happy 10/25

Happy 10/25

Today is the 10 year anniversary of the destruction of the universe frog. Such an occasion is traditionally celebrated by destroying the universe.

Tags

More Posts from Learn-tilde-ath and Others

12 years ago

User input, and a basic calculator.

Most programs people use have some form of user input. A calculator isn't much use if it always uses the same numbers after all!

~ATH of course accepts user input and output as shown in the file Roxy sent Jane.

Also I just found out you can put more than one read more line in one post.

The input command has the syntax:

INPUT VARNAME;

What this does is when program execution meets this line, the program pauses execution, allowing the user to input text. When the user hits enter, program execution will continue and the variable VARNAME will be made to point to an object corresponding to the text the user entered.

This object is such that the left half is the object that corresponds to the first character. If there is no character after that, the right half will be the NULL object. Otherwise the right half will be the object corresponding to the input without the first character. If they hit enter without inputting any characters the object will just be the NULL object.

Now that we have that all explained, we can start to make programs that actually take user input!

As you might have guessed from the title, the thing we will be making is a very basic calculator. All it does is add two numbers, like in the last example.

But in this, it will get the numbers from the user!

One simple way to do this is to use the length of the input text as the number: The way we define what we call numbers just so happens (heh) to be such that if we interpret the object for the input string as a number, the number will be the same as the length of the input!

This isn't the greatest solution, but it is easier than other methods. We will use this method first and then move on to other methods that are harder to write, but will be nicer when using the end program.

HERE WE GO:

ok, so like I said, much of it is pretty much the same as that previous program, so we might as well just include said here:

SOME CODE TO GET A AND B HERE import bluh BLAH; BIFURCATE [BLAH,A]ATEMP; BIFURCATE [BLAH,B]BTEMP; BIFURCATE ATEMP[JUNK,ATEMP]; BIFURCATE BTEMP[JUNK,BTEMP]; BIFURCATE [BLAH,NULL]C; BIFURCATE C[JUNK,C]; ~ATH(ATEMP){ BIFURCATE ATEMP[JUNK,ATEMP]; BIFURCATE [BLAH,C]C; } ~ATH(BTEMP){ BIFURCATE BTEMP[JUNK,BTEMP]; BIFURCATE [BLAH,C]C; } BIFURCATE [BLAH,C]CTEMP; BIFURCATE CTEMP[JUNK,CTEMP]; ~ATH(CTEMP){ BIFURCATE CTEMP[JUNK,CTEMP]; print some text; } print DONE!; 

so pretty much what we need to do it put the code to get A and B where that goes(at the beginning), as well as stuff to tell the user how to print stuff.

Like I said, the objects from the input commands can be interpreted as numbers.

so this becomes:

print INPUT SOMETHING WITH THE NUMBER OF CHARACTERS AS THE FIRST NUMBER YOU WANT TO ADD; INPUT A; print INPUT SOMETHING WITH THE NUMBER OF CHARACTERS AS THE SECOND NUMBER YOU WANT TO ADD; IMPORT B; import bluh BLAH; BIFURCATE [BLAH,A]ATEMP; BIFURCATE [BLAH,B]BTEMP; BIFURCATE ATEMP[JUNK,ATEMP]; BIFURCATE BTEMP[JUNK,BTEMP]; BIFURCATE [BLAH,NULL]C; BIFURCATE C[JUNK,C]; ~ATH(ATEMP){ BIFURCATE ATEMP[JUNK,ATEMP]; BIFURCATE [BLAH,C]C; } ~ATH(BTEMP){ BIFURCATE BTEMP[JUNK,BTEMP]; BIFURCATE [BLAH,C]C; } BIFURCATE [BLAH,C]CTEMP; BIFURCATE CTEMP[JUNK,CTEMP]; ~ATH(CTEMP){ BIFURCATE CTEMP[JUNK,CTEMP]; print some text; } print DONE!; 

So yeah. That should work. I still need to test this, but I am pretty dang sure that this works.(have to go do homework now) In the next post I will explain how to make it so that the user can type in the number as an actual number!


Tags
12 years ago

I am so bad at updating. (and a side note)

I am still intending to update this.

but I am not good at time management.

I have like 2 hours of free time after school, (because of certain inefficiencies on my part) so that's my stupid excuse.

I am working on writing some responses to some requests for clarification, and then I will do the second part of the converter TO binary.

the print command can have the end of a loop in.

The contents of the print command can be executed.

so if you say:

import blah A; import bleh B; ~ATH(A){ ~ATH(B){ print heh } ~ATH(NULL){ print giant frogs alert; B.DIE(); } }  

it should print

"heh } ~ATH(NULL){ print giant frogs alert giant frogs alert"

this of course, is not particularly useful as far as I can tell, except possibly for quines, and possibly obfuscation. but really, is it possibly to write anything in ~ATH that isn't obfuscated?

speaking of not obfuscated, I have started working on adding a feature for user defined functions. I have it pretty much worked out how it will work, but I am not sure how I want to make the user DEFINE the functions. so I haven't been doing NOTHING with regards to this.


Tags
11 years ago

Hello again all!

So recently I started kind of working on this again for a bit. I have fixed some bugs with the parser that I haven't pushed yet. I am also writing an improved interpreter that will use the parser instead of the hacky thing that just goes through strings.

However, for the time being, even after I release this version, I would recommend maybe using the older version for a while if anyone is using it, because this version is probably even more buggy.

However, you know how a few posts ago (but more than a year ago (wow) ) I posted that post where I said that I didn't think bifurcate can be used to split values into more than 2 values?

Well I still kind of think that, but on the map page for homestuck on act 6, it says split Act_6[Act_1,Act_2,Act_3,<etc>];

So this is something I intend to implement, and something I am implementing.

And like I said before I would like it to be done with repeated bifurcation, as a sort of syntactic sugar.

And I am thinking I want it to be like

[a,b,c] means the same thing as [a,[b,c]]

so split Z[A,B,C];

would be the same as

BIFURCATE Z[A,BCTEMP]; BIFURCATE BCTEMP[B,C];

and that split [A,B,C]Z;

would be the same as

BIFURCATE [B,C]BCTEMP; BIFURCATE [A,BCTEMP]Z;

But the way the splits would be done could also be backwards

so [a,b,c] could be the same as [[a,b],c]

I'm pretty sure I prefer the first way, but the second way is actually easier to implement.

or at least cleaner looking to implement.

Why doesn't my code look clean ever?

Anyway, my reason for this post is this:

Does anyone have any opinions about how split is implemented?


Tags
11 years ago

re: "computationalalchemist answered: You could use Prolog-style lists for split."

"computationalalchemist answered: You could use Prolog-style lists for split."

I'm not totally sure what you mean, but my best guess as to what you meant is probably pretty similar to how I making it.

I implemented it and I think it works, I need to double check though.

With what I have now when I use 

split [THIS,THIS,THIS,THIS,THIS,THIS,NULL]COUNTER; ~ATH(COUNTER){ print "bananas"; BIFURCATE COUNTER[JUNK,COUNTER]; }EXECUTE(print "ok";); print "whee!";

it yields 

bananas bananas bananas bananas bananas bananas ok whee!

Which seems to make sense to me, and also, fits with how lisp lists work, and apparently also prolog lists.

also where it says split it will also accept bifurcate. they are actually treated as the same command.

import statements aren't fully implemented yet though.

I think I will put this version on github pretty soon.

Thank you for the advice.


Tags
11 years ago
Learn ~ATH Turned 1 Today!

Learn ~ATH turned 1 today!

yaaaay!

So I think that my explanations of things hasn't been very clear so far, and while I can't promise that they will improve, I do intend to teach programming in person at my school, which might help me to know how to make this tutorial better. Maybe, maybe not. 

May things go well!


Tags
3 years ago

yeah, can i make ~ATH continue to generate variables? like if one part of the program dies it generates another variable? because i've been trying to do that lmfao

Hi. Not sure what you mean by continue to generate variables. If you mean like how in lisp you can like, automatically generate a new variable name and then use that variable name, then no, drocta ~ATH doesn't have a feature like that, but I'm guessing that's not what you mean.

Variables are just like, names in your program. If you want more objects, you can just continue bifurcating objects to get more objects.

drocta ~ATH does not support parallelism or concurrency or whatever (though presumably canonical ~ATH would, in some sense. At least, it appears to handle circumstantial simultaneity.), So, if you are referring to drocta ~ATH, then I'm not sure what you mean when you refer to part of the program dying. Though, given that in canonical ~ATH, there is the expression

[THIS,THIS].DIE();

then it seems like, presumably, it should be possible to have something like

THIS.DIE();

in order to describe part of the program dying (ending), without another part doing so.

But, again, drocta ~ATH does not support anything like that. Feel free to make a fork of it which does though. Please let me know if you do!


Tags
7 years ago

So, I just found this and have no clue what's going on. Could you maybe make, like, a simple guide to programming ~ATH? I understand how your python works, but not how to program ~ATH.

Hi!That is sort of what this blog was meant to be.I was trying to explain how to write programs in it, starting with “how do I represent numbers in it?” but then I started prioritizing other projects.I do want to get back to this one though.Perhaps I can give a brief summary in this ask response, and you can tell me what parts you would like clarification on? I will attempt that. I would appreciate it if you tell me what parts of this explanation you are unclear on, or say more about what you don’t understand about how to use drocta ~ATH.

(drocta ~ATH, as a reminder, is my interpretation of how ~ATH could work, which attempts to stay as true to the comic as it can, while still being turing complete, and also possible to implement in reality)In drocta ~ATH there are things called objects. Every object (except for possibly one depending on the specific version of the interpreter, but that isn’t an important detail.) is initially alive. Once an object dies, it cannot be made alive again.Every object has a left half, and a right half, which are both objects. Just because an object is dead does not mean that its left or right halves are dead. Similarly, just because both an object’s left and right halves are dead does not mean that the object is dead.

Also, for any two objects (possibly the same object), there is an object such that the left half of it is the first object, and the right half of it is the second object.

(skippable sidenote : Yes, this would mean that there are infinitely many objects, but they are only /really/ created by the interpreter when they become relevant, so really there are only ever finitely many that the computer is keeping track of)

A variable, in drocta ~ATH, refers to an object. However, it often does not always refer to the same object at different points during the program.

For example, suppose you want some variable to refer to a number which changes during the program. The way that the number which the variable refers to changes is by changing what object the variable refers to.

There are two ways to change what object a variable refers to.

1:Suppose you have three variables names VAR1, VAR2, VAR3.BIFURCATE VAR1[VAR2,VAR3];will take the left half of the object that VAR1 points to, and make VAR2 point to it, instead of whatever it was pointing to before, if anything, and it takes the right half, and makes VAR3 point to it instead of whatever it was pointing to before, if anything.

2:Again, with three variables VAR1, VAR2, VAR3:BIFURCATE [VAR1,VAR2]VAR3;will take the object pointed to by VAR1, and the object pointed to by VAR2, and finds the object such that the left half is the first one, and the right half is the second one, and makes VAR3 point to this object.

Also, when you initially declare an variable it makes a new object for it.

Now, in order to make an object dead, you take a variable (named, say, examplevariable) which currently points to it, and put examplevariable.DIE();and then the object will be dead. Note that this does not make examplevariable point to a different object, which is the same as the one it pointed to before except for being dead. This actually changes the object.In fact, this is the only operation that actually changes an object.

loops:How do you do control flow with this?Well, you use ~ATH loops.

A ~ATH loop looks like this:

~ATH(SOMEVARIABLENAME){//SOME CODE GOES HERE}

What this will do, is it will check if the object currently pointed to by SOMEVARIABLENAME is dead, and if it is not, it runs the code which is {between the curly brackets}. Then, it checks again if the object currently pointed to by SOMEVARIABLENAME is dead, and if not, runs the code inside again. This keeps on repeating until a time that it checks if SOMEVARIABLENAME currently points to an object which is dead, and it is, at which point the program keeps running after the curly brackets.

Note that which object the variable name points to may be changed by the code inside the curly brackets, and probably will be. Changing which object the variable is pointing to is the main way to make the loop exit.

speaking of, let’s get to numbers:

drocta ~ATH doesn’t have numbers as a built in thing. You have to make up your own numbers. But there is a sort of standard way to do so. Where by “standard” I mean, “it is the way that makes the most sense / is the most obvious, and is the way I usually do it”

if some object is the positive integer n, then an object x which has n as the right half, and some object which is alive as the left half, then that object x is n+1 .1 is an object where the left half is a dead object, and the right half is anything.

The reason for this is because this way you can make loops which do things n times, for n>0.

say the object representing n is pointed to by VAR1 , and VAR2 doesn’t point to anything you care about, but it does point to something which is alive, and VAR3 points to an object which represents 1, but you aren’t using it for anything else. You can make a loop like this:

~ATH(VAR2){BIFURCATE VAR1[VAR2,VAR1]; //decrease VAR1 by 1BIFURCATE [VAR2,VAR3]VAR3; /* increase VAR3 by 1, except if this is the last time through the loop, in which case this makes a small error, but one which will be fixed later *///put the stuff you want in the loop here.//Don’t do things to VAR1, VAR2, or VAR3 that you don’t undo though. 

}BIFURCATE VAR3[JUNK,VAR3]; //removes the extra thing that was added to VAR3.

The result of this is that it will do the code you put in the middle n times, and that VAR3 will still store the number n afterwards.

Following processes like these, it is possible to do basically anything you could with a “counter machine / minsky machine” .

Fortunately, there are also things which make things a bit more convenient than using a minsky machine.

In much the same way that you can create numbers, you can also make lists.Just put the successive entries in the list as left halfs of objects, and have the right halves be the list as made so far. (so, basically, the left half is the first element, and the right half is the rest).A caveat here is to make sure that the left half is never a dead object, because that can make it so that the end of the list is detected pre-maturely. However, you might at some point (if you write a lot of drocta ~ATH, which, I am not certain why you would, haha) find that useful to cut the remaining part of a list off.

Of course, when I say to put something as the left half or right half of an object, feel free to switch that in each case. It doesn’t matter as long as you are consistent.

oh, I left out the parts about how to do input and output .

there are some example files on the github for you to check out which have that?

Please let me know if you have any further questions. I’m not sure which parts of this need clarification, so if part of it is unclear, you would be doing me and any other readers of my blog a favor by asking me to clarify them, so please do not hesitate to ask me to clarify any specific part, or to ask me any other question about ~ATH.

Thank you for your interest,

~drocta / ~hE 

12 years ago

ok, made some small commits...

(no features added, but cleaned up some code and added example programs)

yup.

it has the basis for how I am going to make functions if I make them, and cleaned up the code for BIFURCATEion, and removed some lines that were commented out.

if you want the new version it is on the github.

no real difference when it runs though.

(if something you wrote doesn't work with the new version, try using BIFFURCATE instead of BIFURCATE to use the old code. You probably won't need to, though. It works fine for me. and you probably haven't written anything in it anyway, because you kind of have to uh, want to, I guess)


Tags
12 years ago

How often should I post stuff?

I am still here, and I am wondering what my update schedule for this tutorial should be.

Its been a week or two since I last posted part of the tutorial, so I feel like I probably should have posted during that time, but I haven't.

I will probably post one today.

Do you have any suggestions for what type of update schedule I should keep on this tutorial?

12 years ago

Syntax explanation post completed, and Hello, World.

I have completed the syntax explanation post, and I think it is fairly clear now.

If you find any part of the post to be unclear, and that it requires further explanation,  please say so so that I can improve it.

Now that that post is in an acceptable form, We can get on to writing our first few ~ATH programs.

print Hello, World.; THIS.DIE(); 

That wasn't so hard, was it?

I feel I should note that the syntax of the print command is not entirely finalized, it might change sometime later.

EXPLANATION:

The first line of the program says to output the text "Hello, World." 

The 2nd line of the program says to end the program. This is because the variable THIS initially points to a object that is only alive when the program is running. If the object is ever not alive, the program stops.

oh gosh why is this a bullet-ed list I am not good with tumblr

To run a drocta ~ATH program, you need the interpreter (available from the github), and python 2.7 (the interpreter can be easily modified to run with python 3, but it is written to work in 2.7)

Open interp_2.py with python, and when the program comes up, type in the filename of the ~ATH program, and hit enter, this will run the ~ATH program.

With this example, it should output the text

Hello, World.

Now, of course, this is a relatively simple program, but at least its something.

Depending on how you are running the interpreter, the program might close immediately after outputting the text.

That might not be what we want.

To make the program not close until we specifically tell it to, we use the following:

print Hello, World.; ~ATH(THIS){ } THIS.DIE(); 

EXPLANATION:

The first line is the same as in the first program. It outputs "Hello, World."

The second line is different, this says to start a loop, which will continue until the object pointed to by the variable THIS is dead.

The third line says to go back to the corresponding ~ATH statement.

The fourth line is never executed, because the loop above it will continue until the object pointed to by THIS dies, and if that object dies the program ends. If it were to be executed it would make the object pointed to by THIS die, and the program would end as a result.

This program should be the same, except that it will keep running until you close it manually.

Now you have hello world written in two different ways!


Tags
Loading...
End of content
No more pages to load
  • manorinthewoods
    manorinthewoods liked this · 5 months ago
  • selamat-linting
    selamat-linting liked this · 2 years ago
  • cryptologicalmystic
    cryptologicalmystic liked this · 3 years ago
  • purrhaps
    purrhaps reblogged this · 3 years ago
  • regexkind
    regexkind liked this · 3 years ago
  • soilrockslove
    soilrockslove liked this · 3 years ago
  • problematicescapist
    problematicescapist reblogged this · 3 years ago
  • problematicescapist
    problematicescapist liked this · 3 years ago
  • learn-tilde-ath
    learn-tilde-ath reblogged this · 3 years ago
learn-tilde-ath - Learn ~ATH
Learn ~ATH

News and tutorials on drocta ~ATH by drocta. interpreter here A brief summary of how to write code in the language (but also see the table of contents)

38 posts

Explore Tumblr Blog
Search Through Tumblr Tags