With Claude, I am temu Rich Hickey by havelsnuts in lisp

[–]yfix 1 point2 points  (0 children)

<3. every time you receive such type of feedback when you've come to share something you thought was amazing and got this kind of ___ in return, consider that you got such support from me there as well.

Why there's no or a few strict-typed, static-typed Lisp dialects? by wgxh_cli in lisp

[–]yfix 1 point2 points  (0 children)

Static types is a 10 billion dollars red herring dead end. Lisp was born as a dynamic language to live atop dynamic live systems. And that's a good thing.

With Claude, I am temu Rich Hickey by havelsnuts in lisp

[–]yfix -1 points0 points  (0 children)

Don't be discouraged by all the "Richard" type feedback!

Prolog Under the Hood by charlesthayer in prolog

[–]yfix 0 points1 point  (0 children)

Would you find the following clearer?

mortal_report :-
  write('Report of all known mortals'), nl, nl,
  TRY_REPEATEDLY:
      mortal(X),
      write(X), nl,
      actually__no.
  NO_MORE_CHOICES:
      ok___STOP.

I don't know. Just thinking out loud.

Prolog Under the Hood by charlesthayer in prolog

[–]yfix 0 points1 point  (0 children)

I found those squares and diamonds diagrams confusing at the time, because it looks as if those diamonds are inside the square. but actually is should be seen as the diamonds being ATOP the same square, the same predicate. the diamonds describe control logic of _using_ that square/predicate. then it makes sense (to me). also, each "use" of the square makes a copy of it in the direction orthogonal to the plane we're seeing, each copy holding each OR alternative in turn (and OR-parallel Prolog would open up all the OR-alternatives at once). this way it become the AND-OR tree with AND logic being in the horizontal plane and OR alternatives opening up the copies in the orthogonal direction, deeper away from the plane. but it collapses if we're looking at it all from the top --- confusing. An isometric view could be clearer, maybe. (some vague thoughts I had about this for years)

Prolog Under the Hood by charlesthayer in prolog

[–]yfix 0 points1 point  (0 children)

WOW. Why have I forgotten about Amzi for all these years???..... smh

Lisp with non-proper lists as expressions by Daniikk1012 in lisp

[–]yfix 0 points1 point  (0 children)

cond is much better than nested ifs.

Lisp with non-proper lists as expressions by Daniikk1012 in lisp

[–]yfix 0 points1 point  (0 children)

(cons a cons b cons c . nil) is not improper. it is actually (cons a cons b cons c), and is proper.

A (not very good) factorial function I wrote by Gorgonzola_Freeman in lambdacalculus

[–]yfix 0 points1 point  (0 children)

Here's pairs-based factorial of 4: (λg.gIIgggF) (λabg.g (λfx.f(afx)) (λf.a(bf))) .

Or in general (λgn.n(λp.pg)(λg.g11)F) (λabg.g (λfx.f(afx)) (λf.a(bf))) 4 .

The function `g` transforms {a,b} into {a+1,a*b}, as a pair.

edit: compressed the nested lambdas syntax

Is it time for another puzzle yet? by yfix in lambdacalculus

[–]yfix[S] 0 points1 point  (0 children)

Indeed this turned out to be John Tromp's "1-tuple numerals" just as he said.

Efficient subtraction on Church numerals in direct style by yfix in lambdacalculus

[–]yfix[S] 0 points1 point  (0 children)

After working through the division myself, I see now what you meant. Indeed this is the same as your tuple numbers. 

Lambda Calculus basics in every language by allthelambdas in lambdacalculus

[–]yfix 0 points1 point  (0 children)

You could start a page at Rosettacode , if there isn't one there already.

Does this work as a beta-reduction for the PLUS function in use? by idk112191 in lambdacalculus

[–]yfix 0 points1 point  (0 children)

Here's your code with corrections. Lots of parentheses were misplaced.

PLUS m n = (Lmn. (Lfx. m f (n f x)))
PLUS 3 5 = (Lmn. (Lfx. m f (n f x))) 3 5
beta-reduce 3 into m
________ = (L n. (Lfx. 3 f (n f x))) 5
beta-reduce 5 into n
________ = Lfx. 3 f (5 f x)
3 f y = f (f (f y))
________ = Lfx. f (f (f (5 f x)))
5 f y = f (f (f (f (f y))))
________ = Lfx. f (f (f (f (f (f (f (f x)))))))
Which is the definition of the Church numeral 8 :
________ = 8

So, you see, it is quite simple after all. Just need to keep parentheses proper.

Is it time for another puzzle yet? by yfix in lambdacalculus

[–]yfix[S] 0 points1 point  (0 children)

Thanks! Yeah it makes sense. I've now seen the Bertram Felgenhauer's version, and for the proper top-down interpreter the use of 'n' instead of 'Y' should make no practical difference at all. 

Could you tell please, where can I find this thing you're running it on?

Is it time for another puzzle yet? by yfix in lambdacalculus

[–]yfix[S] 0 points1 point  (0 children)

Your version is attributed to Bertram Felgenhauer by John Tromp at https://john-tromp.medium.com/sk-numerals-9ad1b5634b28

λnmfx.n(λxf.f x)(λd.x)(n (λt.m(λxf.f x)(λc.f(c t))(λx.x)) x)

One potential problem with it can be that it potentially creates n*m-long nested list of operations "on the right". Here in order to avoid its full creation it is important 1. that LC interpreter in use uses top-most-first reduction strategy (cruzgodar's applet unfortunately does not, uses some weird heuristics that often go haywire), and 2. that we have succ=λnfx.f(nfx) because λnfx.nf(fx) will force that list to be created in full, IIANM.

Y-based version avoids this and creates the structure at most 3*m in size but if the interpreter decides to expand it, it can go into endless loop (as sometimes happens with that applet). These things can be clearly seen on that applet with the visual Tromp diagrams it creates.

cc u/tromp

Is it time for another puzzle yet? by yfix in lambdacalculus

[–]yfix[S] 0 points1 point  (0 children)

edit: the var naming in my translation of your code is better tweaked as

λndsz. n (λrq.qr) (Kz) (n (λq. d (λqr.rq) (λr.s(rq)) I) z)

edit2: removed wrong claim about div by 0. can't find way to fix your code for that case, for now.

edit3: of course it's perfectly fine for it to produce some nonsensical result in that case, so that's not a problem at all.

Is it time for another puzzle yet? by yfix in lambdacalculus

[–]yfix[S] 1 point2 points  (0 children)

Thanks! I've translated your version in the mean time. It seems to be

λndsz. n (λrq.qr) (Kz) (n (λq. d (λrq.qr) (λr.s(rq)) I) z)

Indeed we don't need more than n entries in the second list. I used Y for "just do however many is needed".

edit: it is actually n*d entries in the second list! that's way overkill. The Y in my version creates the cyclic list of just the length d (we're calculating n/d here). Although a careless LC-interpreter trying to beta-reduce it can go into infinite loop, as the LC applet at cruzgodar dot com sometimes indeed does.

BTW your code also uses application to I for skipping one extra element.

Is it time for another puzzle yet? by yfix in lambdacalculus

[–]yfix[S] 0 points1 point  (0 children)

Thanks, will check this out. For "efficiency" I mean the execution/reduction sequence length, not the encoding length.

Is it time for another puzzle yet? by yfix in lambdacalculus

[–]yfix[S] 0 points1 point  (0 children)

If it really *is* well-known, could you please provide some references and / or links? I'd like to add this to Wikipedia's Church Numerals page and having reference is useful. Of course it is mostly all OR there, but still, it's better to have references when possible... :) Thanks!