Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6468617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:54:23+00:00 2026-05-25T05:54:23+00:00

(define (mult a b) ;;function mult(a,b) (cond ((IsItZero? b) 0) ;;if b = 0:

  • 0
 (define (mult a b)                    ;;function mult(a,b)
 (cond                                 
 ((IsItZero? b) 0)                     ;;if b = 0: return 0   
 ((let((c (mult a (rest b))))          ;;c = mult(a, floor(b/2))
 (if (= (first b) 0)                   ;;if b is even
 (cons (0 c))                          ;;return 2c else:
 (addTogether(a cons(0 c))))))))       ;;return a + 2c

At the right, in the comments, is some pseudocode given for a multiplication algorithm. On the left is my attempt at implementing said algorithm in, well, real code, taking two lists of binary digits as parameters (From left to right, as opposed to right to left). I get an error when running it that says something along the lines of “procedure application: expected procedure, given: 0; arguments were: 0.” Other functions seen within work perfectly on their own.

Can anyone provide me a hint or nudge in the right direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T05:54:23+00:00Added an answer on May 25, 2026 at 5:54 am

    It’s (cons 0 c), not (cons (0 c)). 🙂 Even so, cons is the wrong approach here. 🙂

    Here’s how I’d translate it:

    (define (mult a b)
      (if (zero? b) 0
          (let ((c (mult a (quotient b 2))))
            (if (even? b)
                (* 2 c)
                (+ a (* 2 c))))))
    

    A less-literal translation can make the code slightly more readable:

    (define (mult a b)
      (if (zero? b) 0
          (let ((c (mult a (quotient b 2))))
            (if (even? b)
                (+ c c)
                (+ a c c)))))
    

    ETA: Binary digit edition! (Where, say, 4 is represented as '(0 0 1).)

    (define (mult a b)
      (if (null? b) '()
          (let ((c (mult a (cdr b))))
            (if (zero? (car b))
                (cons 0 c)
                (add a (cons 0 c))))))
    

    (where you have to implement add to do binary-digit addition.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(define (lcs lst1 lst2) (define (except-last-pair list) (if (pair? (cdr list)) (cons (car list)
/* #define FOO */ #ifdef FOO #define BAR pirate #else #define BAR ninja #endif
#define INIT_MACRO create(); some(); enviroment(); ... void function(){ INIT_MACRO extra_indented(); normal_indented(); } how do
(define cart-product (lambda (sos1 sos2) (if (null? sos1) '() (cons (cart-prod-sexpr (car sos1) sos2)
#define BOOSTPOOL boost::pool<> BOOSTPOOL GetPool() { BOOSTPOOL AppClass1Pool(sizeof(AppClass1)); return AppClass1Pool; } void* AppClass1::operator new(size_t
(define bootstrap-c-code (define (from-file file-name) (let* ((ip (open-input-file file-name)) (res (read-text-file-from-input-port ip))) (close-input-port ip)
(define a 42) (set! 'a 10) (define a 42) (define (symbol) 'a) (set! (symbol)
I define some Entities which works fine; for meta programming issues. I now need
I define a 'block' of text as all lines between start of file, newline
I define HttpClient in 2 different ways: 1. Plain vanilla: client = new DefaultHttpClient();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.