Learn the Stuck Programming Language - Thread 4: Changes 08-24-2015, 03:56 PM
#1
Syntax();
Learn the Stuck Programming Language - Thread 4: Changes
Click here for Thread 1
Click here for Thread 2
Click here for Thread 3
Learn the Stuck Programming Language - Thread 4: Changes
Click here for Thread 1
Click here for Thread 2
Click here for Thread 3
Table of Contents
- Introduction
- Looping
- Variable Storage
- Other Improvements
- A Few Examples
Chapter 1: Preface
This thread is essentially going to be going over the many changes I've made to the Stuck programming language since the last few threads. If you don't know what Stuck is, or you want to download the interpreter, go here.
Chapter 2: Looping
Two new looping functions have been implemented, a "do this x times" function and a while loop.
- V is the character that starts the "do x times" function.
- V pops an integer and a string of Stuck characters off the stack.
- Using the rest of the remaining stack, it processes the function in the string x number of times, where x is the integer popped off.
- An example would be 1"1+"5V, which woud produce 6.
- V pops an integer and a string of Stuck characters off the stack.
- h is the while loop character.
- h pops two strings of Stuck characters, and a value to modify.
- The first value popped is the body of the while loop, the second is the condition, and the third is the value to modify.
- An example would be 2"32<""2*"h, which produces 32.
- h pops two strings of Stuck characters, and a value to modify.
Chapter 3: Variable Storage
Now, if necessary, you can use a variable stack to store values that you need to keep later. This can be shorter in some cases than just duplicating a value you need to use for calculations, then rotating the stack around, but from what I've found so far from small examples is that is not always the case.
- g pushes the top value from the stack into the variable stack, preserving it in the main stack.
- G pulls an item out of the variable stack.
- This depends on an integer being in the top of the main stack. This value corresponds to the index of the item to be pulled.
- For example, if you had two variables in the variable stack and you wanted the one added first, you would use 0G.
- This depends on an integer being in the top of the main stack. This value corresponds to the index of the item to be pulled.
Chapter 4: Other Improvements
- + now performs summations on lists as well as it's original function.
- ' puts the program in char-mode, so the next value read will be made a length 1 string.
- f now can filter one list based on another that has truthy or falsy values.
- U removes all falsy values from a list.[/font]
- A places the uppercase alphabet on the stack, and a checks to see if a string is all alpha characters.
- w checks if a string is lowercase, W checks if a string is uppercase.
Chapter 5: A Few Examples
If you would want a list of the first 100 primes, you could use:
Code:
100R_'v:fThis would create a list of numbers [1,100], duplicate it, map that list to a bunch of True or False values corresponding to the prime-ness, then filter the first list of numbers by this second list.
Alternatively, you could use:
Code:
100R"_v;0?":UWhich creates a list of number [1,100], and for each one, returns itself if prime or 0 if not, and the use U to remove all the falsy values (i.e. zeroes).
Another example is a new way to do the Fibonacci sequence.
Code:
0 1"_@p+"iV![[Image: CDUAq9d.png]](http://i.imgur.com/CDUAq9d.png)





![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)