Trying to get this code to work, can't understand where to put the argument in and keep getting errors

前端 未结 2 714
礼貌的吻别
礼貌的吻别 2021-01-23 17:13

Define the function iota1(n, m) that takes positive integers n, m with n < m as input, and outputs the list (n,n+1,n+2,...,m)

I\'ve tried switching the code around mu

2条回答
  •  渐次进展
    2021-01-23 18:11

    Welcome to the racket world, my version is here:

    #lang racket
    
    (define (iota1 n m)
      (let loop ([loop_n n]
                 [result_list '()])
        (if (<= loop_n m)
            (loop
             (add1 loop_n)
             (cons loop_n result_list))
            (reverse result_list))))
    

提交回复
热议问题