Well I am trying to debug single map, which I feel is vital to understand my-map function
I tried my-member too but get lots of errors when trying to trace it.
Also, it needs some examples where some input is traced stepwise as it happens in actual recursion.
It would be the most helpful for many scheme beginners like me.
Like say (single-map car '((a b) (c d))) &
(single-map cdr '((a b) (c d))).
I get correct results.
But I don't know how to debug.
Like in C , C++ & java esp on Netbeans I could debug , use watches see values as they are changing and getting updated step by step.
I am unable to do so on scheme.
Tried repl.it scheme editor but cannot see any debugging option.
Whenever I try to put say car / cdr instead of fn & I try it in editor , I get a list without " ' " and when I try to apply same logic recursively on that I get errors.
My efforts so far to debug it on repl.it ...
Code: Select all
(single-map car '((a b) (c d)))
=> (a c)
(car(car '((a b) (c d))))
=> a
(cdr '((a b) (c d)))
=> ((c d))
(car(car ((c d))))
Error: execute: unbound symbol: "d" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons]
(car(car '((c d))))
=> c
(cons (a) (c))
Error: execute: unbound symbol: "c" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons]
(cons '(a) '(c))
=> ((a) c)
(cons a '(c))
Error: execute: unbound symbol: "a" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons]
(cons a c)
Error: execute: unbound symbol: "c" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons]
(cons a c '())
Error: execute: unbound symbol: "c" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons]
(cons (a c) '() )
Error: execute: unbound symbol: "c" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons]
(cons (a) (c))
Error: execute: unbound symbol: "c" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons]
Tried few more now ................
Code: Select all
(cons a b)
Error: execute: unbound symbol: "b" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons]
(cons 'a 'b)
=> (a . b)
(cons (car(car '((a b) (c d)))))
Error: cons: wrong number of arguments (expected: 2 got: 1) [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons]
(car(car '((a b) (c d))))
=> a
(car(cdr(car(car '((a b) (c d))))))
TypeError: undefined is not an object (evaluating 'this.initialize.apply') [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons, cdr]
(cdr '((a b) (c d)))
=> ((c d))
(car ((c d)))
..
Error: execute: unbound symbol: "d" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons, cdr]
(car '((c d)))
=> (c d)
(car '(c d))
=> c
(cons 'a 'c)
=> (a . c)
(single-map car '((a b) (c d)))
=> (a c)
(cons '(a (c)))
Error: cons: wrong number of arguments (expected: 2 got: 1) [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons, cdr, cons]
(cons a '())
Error: execute: unbound symbol: "a" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons, cdr, cons]
(cons 'a '())
=> (a)
(cons 'c '())
=> (c)
(cons (a) (c) )
Error: execute: unbound symbol: "c" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons, cdr, cons]
(cons '(a) '(c))
=> ((a) c)
(cons 'a '(c))
=> (a c)
(cdr '((a b) (c d)))
..
=> ((c d))
(car(car ((c d))))
Error: execute: unbound symbol: "d" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons, cdr, cons]
(car(car '((c d))))
..
=> c
(cdr '((c d)))
..
=> ()
(cons c '())
Error: execute: unbound symbol: "c" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons, cdr, cons]
(cons a '(c))
Error: execute: unbound symbol: "a" [my-map, (anon), single-map, cdr, single-map, cdr, single-map, (anon), single-map, cdr, single-map, cdr, (anon), cons, cons, cons, cdr, cons]
(cons 'a 'c)
=> (a . c)
(cons 'c '())
=> (c)
(cons 'a '(c))
=> (a c)
I cannot understand how I get lists using single-map since as per scheme editor I get lists without ' and program should give error when I reach to cons!