currently learning scheme-lisp using the wizard book. real tough shit, but mind expanding. highly recommended, not for practicality, but for better understanding computational processess.
as an example of using lisp for numerical functions, i will describe a process using newtons method for square roots:
;;;; main function, checks if the guess is good enough, otherwise improves it
(define (sqrt-iter guess x)
(if (good-enough? guess x)
guess
(sqrt-iter? (improve guess x)
x)))
;;;; averages to improve the guess
(define (improve guess x)
(average guess (/ x guess)))
;;;; defines the average function
(define (average x y)
(/ (+ x y) 2))
;;;; sees if a number is "good-enough," meaning within 0.001
(define (good-enough? guess x)
(< (abs (- (square guess) x)) 0.001))
;;;; starts the process
(define (sqrt x)
(sqrt-iter 1.0 x)
this is a very basic process, but it may give you some idea of how lisp operates at a surface level. highly recommended to check out the wizard book aka "Structure and Interpretation of Computer Programs"
/\
/vvvvvvvvvvvv \--------------------------------------,
`^^^^^^^^^^^^ /====================================="
\/ keep a shitty sord handy at all times
Posted at 2022/01/06, 05:47:02Post ID: 5624
[img]https://driftt.neocities.org/wizlain.png[/img]
currently learning scheme-lisp using the wizard book. real tough shit, but mind expanding. highly recommended, not for practicality, but for better understanding computational processess.
as an example of using lisp for numerical functions, i will describe a process using newtons method for square roots:
;;;; main function, checks if the guess is good enough, otherwise improves it
(define (sqrt-iter guess x)
(if (good-enough? guess x)
guess
(sqrt-iter? (improve guess x)
x)))
;;;; averages to improve the guess
(define (improve guess x)
(average guess (/ x guess)))
;;;; defines the average function
(define (average x y)
(/ (+ x y) 2))
;;;; sees if a number is "good-enough," meaning within 0.001
(define (good-enough? guess x)
(< (abs (- (square guess) x)) 0.001))
;;;; starts the process
(define (sqrt x)
(sqrt-iter 1.0 x)
this is a very basic process, but it may give you some idea of how lisp operates at a surface level. highly recommended to check out the wizard book aka "Structure and Interpretation of Computer Programs"
Post 5624:5633
fairly recently. i am not expert by any means. i started learning it when i heard that it could widen your understanding of programming in ways other languages often would not
Post 5624:5636
yeah pretty much |φ_φ|
/\
/vvvvvvvvvvvv \--------------------------------------,
`^^^^^^^^^^^^ /====================================="
\/ keep a shitty sord handy at all times
Posted at 2022/01/11, 14:10:33Post ID: 5624:5642
[post=5624:5633]Post 5624:5633[/post]
fairly recently. i am not expert by any means. i started learning it when i heard that it could widen your understanding of programming in ways other languages often would not
[post=5624:5636]Post 5624:5636[/post]
yeah pretty much |φ_φ|
Post 5624:5642
ive heard before that learning it helps understanding computational logic on a deeper level but i still dont get how it does that. give me the lisp-pill
Posted at 2022/01/11, 14:36:55Post ID: 5624:5645
[post=5624:5642]Post 5624:5642[/post]
ive heard before that learning it helps understanding computational logic on a deeper level but i still dont get how it does that. give me the lisp-pill
Post 5624:5645
as far as i know, using lisp, you write your own functions. no "import math" for example. you have to actually define even some very basic things like squares and square roots etc.. beyond that, things like recursion (when a function calls itself) can be pretty mind bending. you can craft the language around the process/program you are making rather than the vice versa. again, i am no expert, am still working through the book and have little understanding of programming outside of lisp itself.
/\
/vvvvvvvvvvvv \--------------------------------------,
`^^^^^^^^^^^^ /====================================="
\/ keep a shitty sord handy at all times
Posted at 2022/01/11, 14:43:24Post ID: 5624:5647
[post=5624:5645]Post 5624:5645[/post]
as far as i know, using lisp, you write your own functions. no "import math" for example. you have to actually define even some very basic things like squares and square roots etc.. beyond that, things like recursion (when a function calls itself) can be pretty mind bending. you can craft the language around the process/program you are making rather than the vice versa. again, i am no expert, am still working through the book and have little understanding of programming outside of lisp itself.
Post 5624:5647
I've taken a class on scheme and can kinda see how it helps since it's purely functional logic, but I think I'd have to dive deeper to really get it. tbh at the end of the class I was still very rusty and didn't understand how to really actually use it
Posted at 2022/01/11, 15:54:00Post ID: 5624:5652
[post=5624:5647]Post 5624:5647[/post]
I've taken a class on scheme and can kinda see how it helps since it's purely functional logic, but I think I'd have to dive deeper to really get it. tbh at the end of the class I was still very rusty and didn't understand how to really actually use it