[Teaching programming] Lesson two - lazyblog
It wasn't clear, and still isn't to me as of now, how S-exps are counted in a list, for example
;; how many are here? Is it 2?
(((a b c) d))| ;; in the previous solution we implemented 2nd and last | |
| ;; but we did not define proper return values for the edge cases, | |
| ;; this time we will | |
| ;; your task will be to provide those values, as you can imagine | |
| ;; (sum 4 'gatto) does not have an answer | |
| ;; make it so that expressions will return true | |
| ;; a suggestion would be to paste the definitions of 2nd and last | |
| ;; above the exercises and fix the errors you get, by returning proper values |
| ;; write the function "2nd" that given a list of atoms | |
| ;; returns the second atom | |
| ;; return values for illegal cases are up to you | |
| ;; try to be reasonable though | |
| (define 2nd | |
| (lambda (lat) | |
| ;; ... | |
| )) | |
| ;; then write the results for these applications by running your function | |
| (2nd '()) ;; ??? |
It wasn't clear, and still isn't to me as of now, how S-exps are counted in a list, for example
;; how many are here? Is it 2?
(((a b c) d))| ;; given leq? that checks for lists equality | |
| ;; complete the following, so that the result is true | |
| ;; all these exercises can be solved with combinations of | |
| ;; car, cdr, cons | |
| ;; be creative! | |
| ;; this is just an example I solved for you :) | |
| ;; l -> (1 2 3) | |
| ;; m -> (0 1 2 3) |
I hate to use "teaching" and "lesson", but those are the easiest words that come to mind right now.
I will be teaching a friend of mine how to program, from zero to (hopefully) web dev so she can see if it could be something she would like to do for a living.
To give her the basic concepts I am going to use The Little Schemer. I feel like it's
It started in March 2017 and it ended this afternoon 19/09/2017, when I finally realised I am going to sign with this company.
1) Write an algorithm (choose the language you prefer) that given a character string, for instance {‘c’,’a’,’i’,’o’,’p’,’a’}, will print out the list of characters appearing at least 2 times. In this specific example, it would return {‘a’}. Afterwards, comment out the cost in terms of space and time.
// I've left out validation to concentrate on the algorithm itself, I hope it's ok
// O(n) timeA lot of time has passed since I willingly wanted to learn a frontend JS framework, I am doing it again because
So recently I've been interviewing and as you can imagine that means doing take home problems and online tests.
I am not pointing fingers (so please continue hiring me lol), I am addressing the problem in the industry, because almost everyone is doing it in the same way, so you could say no one is directly responsible. Even though willingness to have a better process should be a thing.
This is a blog post / diary of my journey through this task, as I'm writing this words I have no idea how and if I will be able to achieve the goal. But, if you're reading this, then probably there's hope.
racket/trace prints calls to a function, that could be useful when dealing with recursion: