乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 45|回复: 7

[编程交流] 无限循环

[复制链接]

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 06:45:51 | 显示全部楼层 |阅读模式
你好
 
调用此函数后:
 
  1. (defun getLowest ()
  2. (setq val (list 309.011 120.605 200.445 670.225))
  3. (while (vl-list-length val) <= i)
  4. (princ "Enter loop")
  5. (setq i (+ i 1))
  6. ) ;_defun
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 06:59:43 | 显示全部楼层
检索排序列表第一项的y值(查看c*r函数);或者,由于您只需要最低的y值,因此不需要对整个列表进行排序,只需使用foreach函数逐步遍历原始列表中的每个项目,并将每个项目的y值与之前存储的最低y值进行比较。
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 07:05:45 | 显示全部楼层
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 07:18:41 | 显示全部楼层
 
The correct syntax would be:

[code](while (
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 07:23:42 | 显示全部楼层
 
what is the right syntax to advance i by 1 so the while loop will stop when it get to the last item of the list?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 07:35:16 | 显示全部楼层
 
You would need to assign a numerical value to the symbol i before the while loop expression; however, to simply iterate over every item in a list, the foreach function is more suitable.
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 07:41:26 | 显示全部楼层
i get this code to sort coordinates by thier Y value, now how can i return the lowest Y value?
 
  1. (defun main () (vl-sort '((1 3) (2 2) (3 1) (3 1)) (function (lambda (e1 e2) (< (cadr e1) (cadr e2)))))) ;_defun
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 07:51:03 | 显示全部楼层
Retrieve the y-value of the first item of the sorted list (look into the c*r functions); alternatively, since you only require the lowest y-value, you needn't sort the entire list, but simply step through each item in the original list using the foreach function, and compare the y-value of each item with a previously stored lowest y-value.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 15:15 , Processed in 1.713600 second(s), 68 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表