开发者

Sum a list without recursion/looping in Scheme/Racket

开发者 https://www.devze.com 2023-04-13 07:05 出处:网络
I\'m working on an assignment involving Racket and I was hoping somebody could lead me into the right direction.

I'm working on an assignment involving Racket and I was hoping somebody could lead me into the right direction.

I must calculate the norm of a list without recursion or using a loop and without defining any helper functions.

Is this possible? The only thing that comes to mind is to someh开发者_开发知识库ow use the built-in map functions


(define (norm lst)
  (apply + (map square lst)))
0

精彩评论

暂无评论...
验证码 换一张
取 消