@vaporeon_ (i say "pure lambda calculus" but i'm using if statements and purrimitive types. you COULD actually do this in Pure Lambda Calculus but it would be a bit obnoxious)

@vaporeon_ it enables recursion-like behavior in with just lambda abstraction and application:

# (fun f n -> if n == 0 then 1 else n * f f (n - 1))
(fun f n -> if n == 0 then 1 else n * f f (n - 1))
6;;
- : int = 720

@vaporeon_ yeah the purroblem is that the function takes an argument that is of the same type as the function itself. if it were pawsible to (safely) type it it would be a recursive type!

@vaporeon_ potentially fun question: why did i have to use a void pointer fur the type of the furst argument to fac?

@vaporeon_ the fact that printf template strings allow quines to happen is more or less the same idea as this hack to do general recursion without explicit recursion

#include <stdio.h>

int fac(void *f, int n) {
int (*g)(void *, int) = f;

if (n == 0) {
return 1;
}
return n * g(f, n - 1);
}

int main(void) {
printf("6! == %d\n", fac(&fac, 6));
}

a technique that is generalizable, btw. (not that you would ever need to use the Y combinator in any purractical situation)

@vaporeon_ i don’t have any experience writing quines so i don’t really have much to say besides “nice, that’s sick”

@coriander @wallhackio @Lady idk if i like “panting like a dog” purr se but panting is definitely hot

like i’ve literally done this befur, i'm not learning anything aside from what i’ve furgotten. though thankfully i have furgotten enough fur some of the purroblems to be conceptually challenging

Show thread

doing the functional purrogramming course furmerly known as the NICTA course not even fur learning but just fur the love of the game

@vaporeon_ a tabby is a cat with an M-shaped fur pattern on its forehead and stripes on its body. color is not relevant

@vaporeon_ is he… *gestures with hands in an inexplicably homophobic manner* unsigned?

not really sure why they felt the need to recreate Write Once Run Anywhere when it just compiles to native code by default anyway

Show thread

i furgot that OCaml has a completely optional bytecode interpurreter fur some goddamn reason

Show older
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.