racket struct与list操作示例代码

代码语言:racket

所属分类:数组

代码描述:racket struct与list操作示例代码

代码标签: list 操作 示例

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

#lang racket
(struct dog (name breed age))
(define my-pet
  (dog "lassie" "collie" 5))
my-pet ; => #<dog>
; returns whether the variable was constructed with the dog constructor
(dog? my-pet) ; => #t
; accesses the name field of the variable constructed with the dog constructor
(dog-name my-pet) ; => "lassie"

; You can explicitly declare a struct to be muta.........完整代码请登录后点击上方下载按钮下载查看

网友评论0