fold

How do foldl and foldr work, broken down in an example?

房东的猫 提交于 2020-12-30 08:44:34
问题 Okay, I am new with scheme/racket/lisp. I am practicing creating my own functions, syntax, and recursion, so I want to make my own foldl and foldr functions that do exactly what the predefined versions do. I can't do it because I just don't understand how these functions work. I have seen similar questions on here but I still don't get it. Some examples broken down would help! Here is my (incorrect) process: (foldl - 0 '(1 2 3 4)) I do 0 -(4-3-2-1) and get 2 which is the right answer (foldl -

How do foldl and foldr work, broken down in an example?

谁都会走 提交于 2020-12-30 08:44:12
问题 Okay, I am new with scheme/racket/lisp. I am practicing creating my own functions, syntax, and recursion, so I want to make my own foldl and foldr functions that do exactly what the predefined versions do. I can't do it because I just don't understand how these functions work. I have seen similar questions on here but I still don't get it. Some examples broken down would help! Here is my (incorrect) process: (foldl - 0 '(1 2 3 4)) I do 0 -(4-3-2-1) and get 2 which is the right answer (foldl -

Implementing powerset in scheme

笑着哭i 提交于 2020-12-11 05:05:53
问题 I am trying to implement a powerset function in Scheme in two ways. One way is using tail recursion, and I did it like this: (define (powerset list) (if (null? list) '(()) ;; if list is empty, its powerset is a list containing the empty list (let ((rest (powerset (cdr list)))) ;; define "rest" as the result of the recursion over the rest of list (append (map (lambda (x) (cons (car list) x)) rest) ;; add the first element of list to the every element of rest (which is a sublist of rest) rest))

Isotope folded (elements overlap)

核能气质少年 提交于 2020-07-16 16:28:34
问题 I have been reading stack overflow for a solution but can't find it. ( full size image at http://i.imgur.com/hrcDg.png ) When I load the page it looks like that Here is the site (beta) http://e-gimnazija.hostoi.com/test/site/index.html If you press all it unfolds, maybe I can solve it if it auto unfolds at the start 回答1: The problem is that when you run .isotope the images are not yet loaded, so the plugin cannot calculate their size.. You have some different options to choose from Start

Isotope folded (elements overlap)

半腔热情 提交于 2020-07-16 16:27:07
问题 I have been reading stack overflow for a solution but can't find it. ( full size image at http://i.imgur.com/hrcDg.png ) When I load the page it looks like that Here is the site (beta) http://e-gimnazija.hostoi.com/test/site/index.html If you press all it unfolds, maybe I can solve it if it auto unfolds at the start 回答1: The problem is that when you run .isotope the images are not yet loaded, so the plugin cannot calculate their size.. You have some different options to choose from Start