Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** johnnymacs (~user@c-73-221-174-12.hsd1.wa.comcast.net) has joined channel #clschool
- <johnnymacs> how do I do a lisp lambda inside of regular calculus math
- <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))
- <pjb> regular calculus math is math. There's little connection with programming.
- <johnnymacs> If I can get a lambda expression to translate into math I can make some sense of it as a computer
- <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 |#
- <pjb> johnnymacs: now, this is performed numerically as you can see. a lambda expression in lisp evaluates to a function (a computer procedure).
- <johnnymacs> ya it is turing complete via floats
- <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 |#
- <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.
- <johnnymacs> well I know sigma ks kinda like a for loop
- <pjb> So you can define a derivate function such as (derivate '(+ (* x x) (* 4 x) 2) 'x) -> (+ (* 2 x) 4)
- <johnnymacs> save these logs would ya. I need to copu them on my pc
- <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.
- *** johnnymacs is unknown (~user@c-73-221-174-12.hsd1.wa.comcast.net)
- *** johnnymacs is on channel(s): #clschool #lispcafe
- *** johnnymacs is/was on server tepper.freenode.net (US)
- *** johnnymacs is logged in as johnnymacs
- <johnnymacs> i like the krivine machine for lambda calculus. johnmorrisbeck/krivine on github
- <johnnymacs> in shotty js
- <johnnymacs> krivine machine is like 12 k of storage in asm
- <pjb> It would be a nice exercice to convert it to lisp.
- <johnnymacs> thata not important tho
- <johnnymacs> your derivative func helps
- <johnnymacs> is all of calculus just deriving?
- <pjb> Not just deriving, but it's a big part. Check your math lessons.
- <pjb> Have a look at maxima.
- <johnnymacs> here is my thought, and it will take me a minute to type it on my phone
- <pjb> Try to dictate it?
- <johnnymacs> I can incode a y coordinate of 0 as an a or 1 as a b and 2 as a c etcetera
- <johnnymacs> then 27 as A
- <johnnymacs> 53 as 0
- <johnnymacs> so string output
- <johnnymacs> ya?
- <johnnymacs> *encode
- <pjb> ok.
- <johnnymacs> similarly I can have string input through x coordinate
- <johnnymacs> and I know piecewise functions can give me things like logical nand
- <pjb> So https://pastebin.com/ymUUMQkt
- <johnnymacs> save this log I cant open it until I finish cooking
- <pjb> you could also copy and paste on the iphone no?
- <johnnymacs> im on androif
- *** johnnymacs (~user@c-73-221-174-12.hsd1.wa.comcast.net) has quit: Remote host closed the connection
- #clschool
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement