I was able to make a scheme code to add two cons lists in scheme. say , list1 - '( p . d) list 2 ' ( p p p . d) my custom add function using cdr & car concepts , can do ( p p p p . d) as is expected.
However, I now want to multiply both & based on number of p's , I have a custom function that gives me list count . say , for list1 -> 1 list2-> 3
I also can manage to detect if any one of two lists is empty , so I output 'd.
But the real issue is when it comes to multiplication. list1 - '(p p . d) list2 - '(p p p p p . q) result expected - (2 * 5 = 10 p's) so '(p p p p p p p p p p . z)
I tried using while loop , do while , add custom function , but I cannot seem to figure out how to do it. Maybe some guidance can help me :)
I want to build a custom function since I don't wish to use a set ! or anything that makes process easier but want to understand recursion the way it could work in this case :).
d
andz
? Usually the sum of two lists are the standard procedureappend
but it cannot do dotted lists since(a . b)
appended to(a . b)
is(a a . b)
according to you, but what about the first listsb
?? You have written code you say, but where is it? If you want help you need to show some effort. – Sylwester