How to resolve the algorithm Create a file step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Create a file step by step in the J programming language

Table of Contents

Problem Statement

In this task, the job is to create a new empty file called "output.txt" of size 0 bytes and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Create a file step by step in the J programming language

Source code in the j programming language

'' 1!:2 <'/output.txt'   NB. write an empty file
   1!:5 <'/docs'         NB. create a directory


require 'files'
NB. create two empty files named /output.txt and output.txt
'' fwrite '/output.txt' ; 'output.txt'

require 'general/dirutils'   NB. addon package
NB. create two directories: /docs and docs:
dircreate '/docs' ; 'docs'


  

You may also check:How to resolve the algorithm Lucky and even lucky numbers step by step in the Ruby programming language
You may also check:How to resolve the algorithm Simple windowed application step by step in the IDL programming language
You may also check:How to resolve the algorithm Huffman coding step by step in the D programming language
You may also check:How to resolve the algorithm Hamming numbers step by step in the QBasic programming language
You may also check:How to resolve the algorithm Determinant and permanent step by step in the Racket programming language