smlnj 重新表述了 listdir(文件名, 目录名) 的问题

发布于 2024-07-15 07:12:24 字数 673 浏览 5 评论 0原文

我是一个学习 sml 的新手,我遇到的问题涉及 IO 函数,即使读完它我也不知道它是如何工作的。 这是我真正需要帮助才能开始的两个问题,请为我提供编码和一些解释,我将能够使用针对其他问题给出的代码进行试验和错误。

Q1) listdir(filename,directoryname),给出目录的名称,在文本文件中列出其内容。 该列表的形式可以轻松区分文件名、日期和大小。 (类似于 msdos 对“dir”所做的操作,但它不是仅仅列出它,而是将所有文件和详细信息放入一个文本文件中。Q2

) readlist(filename) 读取文件名列表(每个文件名都由 listdir 生成)在(Q1)中并将它们组合成一个大列表(从Q1中的文本文件中读取,然后将内容分配到包含所有信息的1个大列表中)

事情是,我只是从学校讲师的介绍部分学到的,甚至没有显示系统输入或输出示例,甚至没有教授“使用文件”功能,如果任何了解 sml 的人看到这一点,请帮助我,谢谢您的

回复 。我正在使用 SMLNJ 尝试执行此操作。基本上,Q1 要求我将提供的“目录名”的目录文件列出到“文件名”中的文本文件中。Q2 要求我从“文件名”文本文件中读取,然后放置。 将内容

复制到一个大列表中:smlnj listdir

i am a newbie learning sml and the question i am thrown with involves IO functions that i have no idea how it works even after reading it. Here is the 2 questions that i really need help with to get me started, please provide me with codings and some explaination, i will be able to trial and error with the code given for the other questions.

Q1) listdir(filename,directoryname), which given the name of a directory, list its contents in a text file. The listing is in a form that makes it easy to seperate filenames, dates and sizes from each other. (similar to what msdos does with "dir" but instead of just listing it out, it places all the files and details into a text file.

Q2) readlist(filename) which reads a list of filenames (each of which were produced by listdir in (Q1) and combines them into one large list. (reads from the text file in Q1 and then assigning the contents into 1 big list containing all the information)

Thing is, i only learned from the lecturer in school on the introduction section, there isnt even a system input or output example shown, not even the "use file" function is taught. if anyone that knows sml sees this, please help. Thanks to anyone who took the effort helping me.

Thanks for the reply, current I am using SMLNJ to try and do this. Basically, Q1 requires me to list the directory's files of the "directoryname" provided into a text file in "filename". The Q2 requires me to read from the "filename" text file and then place the contents into one large list.

Duplicate of: smlnj listdir

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨巷深深 2024-07-22 07:12:24

作为提示,我会说你必须使用这些函数:

OS.FileSys.OpenDir(directoryname) - 这将为你打开目录流(Q1)
TextIO.openOut(filename) - 这将打开文件流 (Q2)

TextIO.openIn(filename) - 这将打开文件 (Q2)
如果您遇到困难并且不知道如何进行编程,那么我将在此处发布完整的代码,但我建议您首先尝试一下。


祖拜尔·谢赫

As a hint I will say that you have to make use of these functions:

OS.FileSys.OpenDir(directoryname) - this will open directory stream for you (Q1)
TextIO.openOut(filename) - this will open the file stream (Q2)

TextIO.openIn(filename)- this will open the file (Q2)
If you are stuck and dont' know how to do the progs then I will post the full code here, but i suggest you first give a try.


zubair sheikh

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文