You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Factor语言整数转字符串实现问题求助

在Factor语言中实现整数转字符串遇到的问题

我在Factor语言中尝试将整数转换为字符串时遇到了困难,找到的相关教程难以理解,已经试过以下几种写法,但都没成功:

  • 尝试1:
USING: kernel ;
IN: number-to-string
: number-to-string ( n -- str )
    [ "%d" format ] dip >string ;
  • 尝试2:
USING: kernel ;
IN: number-to-string
: number-to-string ( n -- str )
    "%d" sprintf ;
  • 尝试3:
IN: number-to-string
: number-to-string ( n -- str ) >string ;
  • 尝试4:
USING: strings ;
IN: number-to-string
: number-to-string ( n -- str )
    number>string ;

以下是我使用的测试用例:

USING: number-to-string tools.testest ;
IN: number-to-string.tests

: run-tests ( -- )
  "Fixed tests" describe#{n    "should satisfy fixed tests" it#{n      <{ 67 number-to-string -> "67" }>n    }#n  }#n;

MAIN: run-tests

内容的提问来源于stack exchange,提问作者Stefan Glova

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 22:13:10