title: How to debug "List contains heterogenous data types" in Racket?
body: <p>Here is my Racket problem:</p>
  
  <blockquote>
    <p>Define a function that takes a list as an argument. It should return a boolean (i.e. #t or #f) indicating whether the list is sorted in ascending order. You may not use the built-in sorted? function. Your implementation must be recursive.</p>
    
    <p><strong>Input:</strong> A list of elements of homogenous data type, either numbers or strings.</p>
    
    <p><strong>Output:</strong> A boolean value that indicates whether the elements of the list are sorted in strictly increasing order. If the list contains heterogenous data types, then throw an error (using the error function) with the message “ERROR: List contains heterogenous data types”.</p>
  </blockquote>
  
  <p>So when I type this function have to gave me this ERROR</p>
  
  <blockquote>
    <p>(my-sorted? '(7 "spam" 9))
    ! ERROR: List contains heterogenous data types</p>
  </blockquote>
  
  <p>BUT for mine its gave me this </p>
  
  <blockquote>
    <p>(my-sorted? '(7 "spam" 9))
    : contract violation
      expected: real?
      given: "spam"
      argument position: 2nd
      other arguments...:</p>
  </blockquote>
  
  <p>Here what I have </p>
  
  <pre><code>(define (my-sorted-int? lst)
    (define size (length lst))
    (if (&lt; size 2)
        #t
        (if (null? lst)
            #t
            (if (&gt; (car lst) (car (rest lst)))  &lt;======= Gave me Error
                #f
                (my-sorted-int? (rest lst) )))))
  
  (define (my-sorted-string? lst)
    (define size (length lst))
    (if (&lt; size 2)
        #t
        (if (null? lst)
            #t
            (if (string&gt;? (car lst) (car (rest lst)))
                #f
                (my-sorted-string? (rest lst) )))))
  
  (define (my-sorted? lst)
    (if (string? (car lst))
        (my-sorted-string? lst)
        (my-sorted-int? lst)))
  </code></pre>