The L Programming Language
theangryepicbanana (1530)

The L Programming Language

This is a programming language that I made as my final project for my CS class this past year (for those of you who are curious, I got a 98% on it). It ended up turning out much better than I had expected, so I thought it'd be cool to share it here on Repl Talk.

What is L?

L is an array-oriented programming language made for performing complex operations on large sets of data. It is inspired by languages of the same category such as R, Julia, and J (which was my main inspiration).

While it appears to be an abstract mess of symbols at first, the conciseness of using symbolic operators as opposed to named functions allows you to do more by doing less.

About J

J was my main inspiration for L. I had found J a few months ago after doing some stuff for the APL language mode here on, mainly because J is highly influenced by APL (minus its Unicode character set).

The core concept in both languages is that you can create new functions by composing existing functions, all of which can either be a unary operator (monadic; takes one value) or a binary operator (dyadic; takes 2 values). While L does not allow you to compose functions (that would have taken way more work and I didn’t have time for that anyways), it does have the monadic and dyad operator features.

Another core concept is that when you perform operations on an array of values, the operation is performed on each value of the array. For example, doing 1 2 3 + 1 will give you 2 3 4 as a result. If you perform a binary operation on 2 arrays of the same length, it will perform the operation on each element of the arrays in parallel. For example, doing 1 2 3 + 4 5 6 will give you 5 7 9.

If I had more time…

If I had more time to work on this, I would have added things like:

  • More mathematical operators (log, trig, etc).
  • More statistical operators (min, max, average, etc).
  • More operators in general.
  • “Boxed” sets (that don’t perform operations on every value it has).
  • “Flat” sets (opposite of above but one level deeper (if that makes sense)).
  • User-defined functions/operators.
  • “Lazy” expressions that can be assigned to variables and aren’t evaluated until they’re referenced/used.
  • Better documentation.


Because the original documentation for my project is super long (too long for a Repl Talk post), I've included it in the repl files as a PDF (file name is Docs.pdf).



num: 5
{* (1..num)

Filter numbers between (min, max]

range: 1..10
min: 2
max: 8
range ?> min ?<= max

Prime number checker

num: 17
#(num / (2..num-1) % 1 ?= 0) = 0

Future thoughts

Might try adding more features to this in the future like user-defined functions or something. Also might try rewriting this in Rust since it'd have less boilerplate than doing it like this in C++

You are viewing a single comment. View All
StudentFires (292)

Might I suggest using C++'s <valarray> to have done the same thing and save you some time?

theangryepicbanana (1530)

@StudentFires <valarray> wasn't taught in the book that the curriculum used, so I couldn't use it :/

StudentFires (292)

@theangryepicbanana What? It wasn't taught so you couldn't use it? That's extremely unfortunate. If my teachers were like that, I don't know what I would've done.

theangryepicbanana (1530)

@StudentFires yeah ikr.
? I couldn't use all of the helpful stuff like <any>, <optional>, <functional>, lambdas, or namespaces because they weren't in the book. Thankfully snart pointers were though :)

StudentFires (292)

@theangryepicbanana I use lambdas, namespaces, and std::functions quite often. Btw, using G++ with std=c++17, allows you to do stuff like auto f(auto x, auto y). Were you allowed to use templates? What compiler could you use?

Though, might I ask, why did you use .h files instead of .hpp?

theangryepicbanana (1530)

@StudentFires Re: templates, yes we could use them, but we could only use type templates (so we couldn't use literals or constraints in the template parameters). Re: compiler, we were forced to use VS2019 for everything in the course. Re: .h/.hpp, VS didn't seem to have an option to use .hpp for headers

StudentFires (292)

@theangryepicbanana I've never used VS2019, I doubt it supports 2020 C++ though. Was this a college class or what?

theangryepicbanana (1530)

@StudentFires it's just a college class for highschool

StudentFires (292)

@theangryepicbanana I forgot you said it was an AP class.