haasn / -g-pl

/g/ programming language
13 stars 2 forks source link

"100% accurate" form for functions #21

Open IDM350 opened 10 years ago

IDM350 commented 10 years ago

>implying it isn't >function(x) >... looks like a clusterfuck, and I though of a different way to define functions, based on:

Install a program on Windows:
>...
>...
OS X, Linux:
>...
>...
100% accurate

Assuming this is code, this is the function "Install a program" - one form with a parameter as "Windows" and the other form with two parameter named "OS X" and "Linux"

factorial on n:
    >is n 0; TIER: 1
    SHIT TIER: >mul n >this >sub n 1;;;    inane The >this ; form calls itself
    100% accurate
n, p:
    >is p 1; TIER: n
    SHIT TIER: >mul n >this >sub n 1; >sub p 1;;;
    100% accurate
100% accurate

IDM350 commented 10 years ago

AMENDMENT on return values

I looked at the function above, and there was no well-defined way to return a value. Rather than the obscure shit - apparently referencing a value and doing nothing with it to set, I'll put in a well-defined ebin result for returning a value.

factorial on n:
    >is n 0; TIER:
        ebin 1
    SHIT TIER:
        ebin >mul n >this >sub n 1;;;    inane The >this ; form calls itself
    100% accurate
n, p:
    >is p 1; TIER:
        ebin n
    SHIT TIER:
        ebin >mul n >this >sub n 1; >sub p 1;;;
    100% accurate
100% accurate

Other forms which aren't used for anything yet: b-but [expression] or b-but muh [name] inb4 [expression] Checkmate, [name] Daily reminder that [expression] Prove me wrong (optionally Protip: you can't) [name (optional)] BOTNET [name] is a faggot pleb or Stay pleb, plebs. [name (optional)] shill, maybe shill pls go