乐筑天下

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

[编程交流] 递归问题

[复制链接]

53

主题

302

帖子

249

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
265
发表于 2022-7-5 17:05:36 | 显示全部楼层
 
根据您上次的回复(流量200.0 150.0)=>21.09;那么你是怎么得到q=0.0的?这不是q=21.09吗
回复

使用道具 举报

53

主题

302

帖子

249

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
265
发表于 2022-7-5 17:09:45 | 显示全部楼层
我首先用(>q a)运行它,我给出了(150.0 120.00)的结果,然后用(
命令:
命令:\u appload test3。LSP已成功加载。
命令:
命令:
命令:测试
14.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.935
流量值为:零;管道直径为:零;梯度为:零
命令:
 
这些似乎是一系列小数点后四位的数字,可能是直径和斜率(或梯度)在流量函数中混合在一起,而不是使用每个直径的专用集。
当做
芦荟
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 17:10:39 | 显示全部楼层
我已经完成了以下数据重排代码的一半:
  1. (defun disets()  
  2. (setq ql '(6.0 9.0 28.0 40.0 55.0 66.0 72.0 110.0 120.0))
  3. (setq diql '((150.0 ((120.0 10.97) (110.0 11.46) (100.0 12.02)))
  4.      (200.0 ((150.0 21.09) (140.0 21.83) (120.0 23.58)))
  5.      (225.0 ((180.0 26.34) (170.0 27.10) (160.0 27.94) (150.0 28.85)))
  6.      (300.0 ((300.0 43.86) (280.0 45.40) (260.0 47.11) (250.0 48.04) (220.0 51.21) (200.0 53.71) (180.0 56.62)))
  7.      (375.0 ((350.0 73.51) (320.0 76.88) (300.0 7940) (280.0 82.19)))
  8.      (450.0 ((400.0 111.69) (370.0 116.13) (350.0 119.40 (320.0 124.87)))
  9.      (600.0 ((500.0 214.17) (450.0 226.35) (400.0 240.08))))))
  10. )

由于q的返回值已经包含在子列表中,其中第一项包含在子列表中,因此不需要使用“(流d i)”函数。在调试时,我发现代码可以运行到第十三个子列表(即(28.85 225.0 150.0))。第一个数字是q值,然后是直径和斜率(或梯度)。然后,整个函数“test”突出显示,调试终止。有没有办法强制控件使用test1函数来完成它。
任何帮助都将不胜感激。
 
芦荟。
回复

使用道具 举报

53

主题

302

帖子

249

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
265
发表于 2022-7-5 17:16:39 | 显示全部楼层
我在过去两天一直在研究它,我发现解决方案之一如下:
  1. 4

可以看出,这个解决方案和我在第14篇文章中手工选择的解决方案是一样的。
感谢Grrr和Marco的帮助/建议。
 
当做
芦荟
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 17:18:39 | 显示全部楼层
回复

使用道具 举报

53

主题

302

帖子

249

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
265
发表于 2022-7-5 17:22:59 | 显示全部楼层
Well I first ran it with (> q a) I gave the result for (150.0 120.00) and then with (
Command:
Command: _appload test3.LSP successfully loaded.
Command:
Command:
Command: TEST
14.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.93514.348314.986315.717727.585528.553830.841634.447435.446136.53737.735357.354759.367861.608962.82964.124666.975970.244974.0447103.836100.53996.1339146.05151.856156.134280.792295.981313.935
Value of flow is : nil; diameter of pipe is : nil; gradient is : nil
Command:
 
It appears these are series of numbers with four decimal places, perhaps the diameters and slopes (or gradients) got mixed up in the flow function instead of using the set dedicated for each diameter.
Regards,
Aloy
回复

使用道具 举报

53

主题

302

帖子

249

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
265
发表于 2022-7-5 17:27:30 | 显示全部楼层
I have been able to go halfway through with the following code with rearrangement of data:
  1. (defun diqsets()   (setq ql '(6.0 9.0 28.0 40.0 55.0 66.0 72.0 110.0 120.0))  (setq dl '((10.97 150.0 120.0) (11.46 150.0 110.0) (12.02 150.0 100.0)     (21.09 200.0 150.0) (21.83 200.0 140.0) (23.58 200.0 120.0)     (26.34 225.0 180.0) (27.10 225.0 170.0) (27.94 225.0 160.0) (28.85 225.0 150.0)     (43.86 300.0 300.0) (45.40 300.0 280.0) (47.11 300.0 260.0) (48.04 300.0 250.0) (51.21 300.0 220.0) (53.71 300.0 200.0) (56.62 300.0 180.0)     (73.51 375.0 350.0) (76.88 375.0 320.0) (79.40 375.0 300.0) (82.19 375.0 280.0)     (111.69 450.0 400.0) (116.13 450.0 370.0) (119.40 450.0 350.0) (124.87 450.0 320.0)     (214.17 600.0 500.0) (226.35 600.0 450.0) (240.08 600.0 400.0)))) (diqsets)(defun test( / i qin q iset)    (setq n (length ql)  qin (car ql)    q (caar dl)    i (caddr(car dl)))   (if (and(> q qin) (>= n 1))   (test1)  ) (if(and(> qin q) (>= n 1))   (test2)  ))(defun test1() (if(and(> q qin) (>= n 1))  (progn (while (and(> q qin) (>= n 1))   (setq iset(cons  i iset)                    q (caar dl)            i (caddr(car dl))            n (- n 1)            ql (cdr ql)            qin (car ql))))  (test2)))(defun test2()(if (and(> qin q) (>= n 1)) (progn (while (and (> qin q) (>= n 1))   (setq dl (cdr dl)          q (caar dl)         qin (car ql)             i (caddr(car dl)))  )  )    (test1) ))
There is no need for the '(flow d i)' function as the return values of q has already been included in the sublist with the first item in it. When debugged I find that the code works ok up to the thirteenth sublist (that is (28.85 225.0 150.0). The first figure being the value of q and then the diameter and the slope (or gradient) in that order. Then the whole of function 'test' get highlighted and the debugging terminates. Is there any way to force the control to test1 function to finish it off.
Any help would be very much appreciated.
 
Aloy.
回复

使用道具 举报

53

主题

302

帖子

249

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
265
发表于 2022-7-5 17:29:11 | 显示全部楼层
I have been working on it for the past two days and I find one of the solution is as follows:
  1. (defun diqsets()   (setq ql '(6.0 9.0 28.0 40.0 55.0 66.0 72.0 110.0 120.0))  (setq dl '((10.97 150.0 120.0) (11.46 150.0 110.0) (12.02 150.0 100.0)     (21.09 200.0 150.0) (21.83 200.0 140.0) (23.58 200.0 120.0)     (26.34 225.0 180.0) (27.10 225.0 170.0) (27.94 225.0 160.0) (28.85 225.0 150.0)     (43.86 300.0 300.0) (45.40 300.0 280.0) (47.11 300.0 260.0) (48.04 300.0 250.0) (51.21 300.0 220.0) (53.71 300.0 200.0) (56.62 300.0 180.0)     (73.51 375.0 350.0) (76.88 375.0 320.0) (79.40 375.0 300.0) (82.19 375.0 280.0)     (111.69 450.0 400.0) (116.13 450.0 370.0) (119.40 450.0 350.0) (124.87 450.0 320.0)     (214.17 600.0 500.0) (226.35 600.0 450.0) (240.08 600.0 400.0)))) (diqsets)(defun test( / diset n qin) (setq diset nil) (setq n (length ql))(setq qin (car ql)    q (caar dl)    d (cadr(car dl))    i (caddr(car dl)))   (while (>= n 1) (if (and(> q qin) (>= n 1))    (progn (while (and(> q qin) (>= n 1))   (test1)))  ) (if(and(> qin q) (>= n 1))   (progn (while (and (> qin q) (>= n 1))   (test2))))    ) (setq diset(reverse diset)) (prompt "\nList of Diameters and Slopes is: ") (princ diset) (princ)) (defun test1() (if(and(> q qin) (>= n 1))  (progn (while (and(> q qin) (>= n 1))   (setq diset(cons  (list d i) diset)                    q (caar dl)            i (caddr(car dl))     d (cadr(car dl))            ql (cdr ql)            qin (car ql)      n (- n 1))))            (test2))  )(defun test2()(if (and(> qin q) (>= n 1)) (progn (while (and (> qin q) (>= n 1))   (setq dl (cdr dl)          q (caar dl)         qin (car ql)  d (cadr(car dl))           i (caddr(car dl)))  )  )     (test1) )  ) AutoCAD menu utilities loaded.Command: _RIBBONCommand: COMMANDLINECommand:Command:Command:Command:Command: _appload SelPipe11K.lsp successfully loaded.Command:Command:Command: (test)List of Diameters and Slopes is: ((150.0 120.0) (150.0 120.0) (225.0 150.0) (300.0 300.0) (300.0 180.0) (375.0 350.0) (375.0 350.0) (450.0 400.0) (450.0 320.0))
As can be seen this solution is same as hand selected solution in my post No. 14.
Thanks Grrr and Marco for trying to help/advise.
 
Regards,
Aloy
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 13:09 , Processed in 0.379753 second(s), 66 queries .

© 2020-2025 乐筑天下

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