Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. *** johnnymacs (~user@c-73-221-174-12.hsd1.wa.comcast.net) has joined channel #clschool
  2. <johnnymacs> how do I do a lisp lambda inside of regular calculus math
  3. <pjb> I'm not sure what you mean. A lambda list is a list of parameters. A lambda expression is a lambda form such as: (lambda (x) (* 2 x))
  4. <pjb> regular calculus math is math. There's little connection with programming.
  5. <johnnymacs> If I can get a lambda expression to translate into math I can make some sense of it as a computer
  6. <pjb> We can write functions such as derivate: (defun derivate (f) (lambda (x dx) (/ (- (funcall f (+ x dx)) (funcall f x)) dx))) (funcall (derivate (lambda (x) (+ (* x x) (* 4 x) 2))) 1 0.001) #| --> 6.001472 |#
  7. <pjb> johnnymacs: now, this is performed numerically as you can see. a lambda expression in lisp evaluates to a function (a computer procedure).
  8. <johnnymacs> ya it is turing complete via floats
  9. <pjb> johnnymacs: but since lisp is homoiconic, which means that lisp source expression and data have the same syntax, we can quote the lambda expression and obtain instead a list: (typep '(lambda (x) (* 2 x)) 'list) #| --> t |#
  10. <pjb> johnnymacs: but in that case, you have to write yourself the program to interpret such expressions. For derivation of simple expressions, it's rather easy to write.
  11. <johnnymacs> well I know sigma ks kinda like a for loop
  12. <pjb> So you can define a derivate function such as (derivate '(+ (* x x) (* 4 x) 2) 'x) -> (+ (* 2 x) 4)
  13. <johnnymacs> save these logs would ya. I need to copu them on my pc
  14. <pjb> Notice that lambda calculus has different evaluation rules than lisp. You could implement a lambda calculus interpreter in lisp, if you're into it.
  15. *** johnnymacs is unknown (~user@c-73-221-174-12.hsd1.wa.comcast.net)
  16. *** johnnymacs is on channel(s): #clschool #lispcafe
  17. *** johnnymacs is/was on server tepper.freenode.net (US)
  18. *** johnnymacs is logged in as johnnymacs
  19. <johnnymacs> i like the krivine machine for lambda calculus. johnmorrisbeck/krivine on github
  20. <johnnymacs> in shotty js
  21. <johnnymacs> krivine machine is like 12 k of storage in asm
  22. <pjb> It would be a nice exercice to convert it to lisp.
  23. <johnnymacs> thata not important tho
  24. <johnnymacs> your derivative func helps
  25. <johnnymacs> is all of calculus just deriving?
  26. <pjb> Not just deriving, but it's a big part. Check your math lessons.
  27. <pjb> Have a look at maxima.
  28. <johnnymacs> here is my thought, and it will take me a minute to type it on my phone
  29. <pjb> Try to dictate it?
  30. <johnnymacs> I can incode a y coordinate of 0 as an a or 1 as a b and 2 as a c etcetera
  31. <johnnymacs> then 27 as A
  32. <johnnymacs> 53 as 0
  33. <johnnymacs> so string output
  34. <johnnymacs> ya?
  35. <johnnymacs> *encode
  36. <pjb> ok.
  37. <johnnymacs> similarly I can have string input through x coordinate
  38. <johnnymacs> and I know piecewise functions can give me things like logical nand
  39. <pjb> So https://pastebin.com/ymUUMQkt
  40. <johnnymacs> save this log I cant open it until I finish cooking
  41. <pjb> you could also copy and paste on the iphone no?
  42. <johnnymacs> im on androif
  43. *** johnnymacs (~user@c-73-221-174-12.hsd1.wa.comcast.net) has quit: Remote host closed the connection
  44. #clschool
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement