\n(define (yani-reverse L) [if (null? L) null [append (yani-reverse (rest L))(list [first L])]])
\n<\/code><\/div>\nIn plain racket, define is used to define functions and variables.
\nThe syntax, comes (define id expr) or (define (head args) body++)<\/code>
\nAbove I defined a function called yani-reverse with L as argument which in this case is a list, parenthesizes and square brackets are interchangeable. I’m doing a if statement that will check if my L ( list) is not null, if it’s null it will return null, if else it will append the last element of the list into an a list with the first element.
\nFirst is the first element of the list and rest of the rest elements of the list. <\/p>\nLets now call our function<\/p>\n
\n
\n(yani-reverse '(a b c d))<\/p>\n(yani-reverse '(1 2 3 4))<\/p>\n
(yani-reverse '( ))<\/p>\n
>
\n'(d c b a)
\n'(4 3 2 1)
\n'()<\/p>\n
<\/code><\/div>\n","protected":false},"excerpt":{"rendered":"
(define (yani-reverse L) [if (null? L) null [append (yani-reverse (rest L))(list [first L])]]) In plain racket, define is used to define functions and variables. The syntax, comes (define id expr) or (define (head args) body++) Above I defined a function called yani-reverse with L as argument which in this case is a list, parenthesizes and […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/posts\/185"}],"collection":[{"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":5,"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":660,"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/posts\/185\/revisions\/660"}],"wp:attachment":[{"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smartvania.com\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}