gpt4 book ai didi

string - Ocaml - 字符串到 (int*int*int) 列表

转载 作者:行者123 更新时间:2023-12-04 11:43:40 24 4
gpt4 key购买 nike

在 ocaml 函数中,它可以将这样的字符串 "[(1,2,3);(1,2,5);(2,3,4)]"解析为 (int*int*int) 列表?还是我必须编写自己的解析函数?

谢谢

格雷格

最佳答案

好吧,在 Scanf 的帮助下应该不会太难。标准库中的模块——您将能够轻松地扫描三元组,然后只需添加一些逻辑来解析列表。

或者,您可以查看 deriving :

Extension to OCaml for deriving functions from type declarations. Includes derivers for pretty-printing, type-safe marshalling with structure-sharing, dynamic typing, equality, and more.

关于string - Ocaml - 字符串到 (int*int*int) 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6388986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com