Advertisement
TangentFox

Figuring out lambda calculus

Apr 23rd, 2019
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 2.00 KB | None | 0 0
  1. -- taking notes while examining the structure, this is when I finally figured out how "two arguments were passed"
  2. -- through the "f" and "x" functions
  3. call a function(1)
  4. f1()
  5. that function is the result of another(2) function being called with a third(B) function
  6. f1 = f2(B)
  7. the second(2) function returns function(f) called with a forth(A) function
  8. f2 = return ff(A)
  9. function(x) is defined by a call to its bound function(F)
  10. fx = F(x)
  11. function(f) binds the passed function and returns function(x)
  12. ff = fx(F)
  13. finally, function(f) is called with function(A) (SEE ABOVE)
  14.  
  15. f1() -> f2(B) -> ff(A)(B) ->
  16. fx(A)(B) -> A(B) -> B
  17.  
  18. ff(A) really means F = A & call fx(B)
  19.  
  20. -- nesting to try to understand it better
  21. (1
  22.   (2
  23.     (λ f .
  24.       (λ x .
  25.         (f x)
  26.       )
  27.     )
  28.     (λ a . a)
  29.   )
  30.   (λ b . b)
  31. )
  32.  
  33. -- attempting a syntax that I understand better
  34. λ x . (f x)     => fn X(x) { return f(x) }
  35. λ f . X f-bound => fn F(f) { return X(f) }
  36. λ a . a         => fn A(a) { return a }
  37. λ b . b         => fn B(b) { return b }
  38. anon creates F, calls it with A, then calls the result with B
  39.                  (F(A))(B)
  40.  
  41. -- literally going in circles
  42. F(A) -> X(A)
  43. X(A) -> F(A)
  44. ?
  45.  
  46. -- trying to distinguish between defining functions and calling them
  47. (
  48.   def(
  49.     def(λ F .
  50.       def(λ X .
  51.         call(F X)
  52.       )
  53.     )
  54.     call(A)
  55.   )
  56.   call(B)
  57. )
  58.  
  59. -- still not realizing that "x" and "f" functions are more dynamic than I expected
  60. anon1 = { return F(A) }
  61. F = (F){ return (X){ F(X) } }
  62. X = (X){ return F(X) }
  63. A = (A){ return A }
  64. B = (B){ return B }
  65. anon1(B)
  66.  
  67. F(B)
  68. λ X . (F X)
  69.  
  70. -- THIS is when I finally got the whole thing
  71. ( ( (λ f . (λ x . (f x) ) ) (λ a . a) ) (λ b . b) )
  72. B = fn(b) -> return b
  73. A = fn(a) -> return a
  74.  
  75. (λ f . (λ x . (f x) ) ) A B
  76. F = fn(f) -> return (λ x . (f x) )
  77. F(A)B
  78.  
  79. λ x . (A x) B
  80. X = fn(x) -> return A(x)
  81. X(B) => A(B) => B
  82.  
  83. λ x . f x  OR  λ x . (f x)  OR  "(x) -> f(x)"  OR  f
  84. "functions are equal if they give the same results on all inputs"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement