title: Scheme Programming: Contract Violation Error in Function when interacting with List
body: <p>I am instructed to perform the following:
  ( insertBag List Item ) -- return a new bag that represents the result of inserting the given item in the given list</p>
  <pre><code>;Function Two: insertBag
  ;@Param: List, Item
  ;@Return: The new bag that represents the result of
  ;inserting the given item in the given list.
  ;Important Note: There are two Helper functions for insertBag
  ;Helper Function One: newPair
  ;Helper Function Two: addPair 
  
  (define (insertBag List Item)
  
   ;Check if we have an Empty List
   (if (null? List)
    (newPair Item)
     
     (if (string=? (car(car List)) Item)
      (cons (addPair (car List)) (cdr List))
      (cons (car List) (insertBag(cdr List) item))
     )
   )
  )
  
  ;Helper Function One: newPair
  
  (define (newPair Item)
   (cons Item 1)
  )
  
  ;Helper Function Two: addPair
  
  (define (addPair List)
   (cons (car List) (+ 1 (cdr List)))
  )
  
  
  ;Test Run Case for insertBag
  (insertBag '((&quot;a&quot;.2)(&quot;d&quot;.1)(&quot;c&quot;.3)) &quot;a&quot;); Input for A
  </code></pre>
  <p>However, I get the following error:</p>
  <pre><code>; +: contract violation
  ;   expected: number?
  ;   given: '(0.2)
  ;   argument position: 2nd
  ; [,bt for context]
  </code></pre>
  <p>Please note that I was instructed to not use lambda. I would appreciate some help!
  Thank you!
  &gt;</p>