Count in octal: Difference between revisions

Content deleted Content added
+ МК-61
Added COBOL example. Corrected PL/I lang tag.
Line 268: Line 268:
=={{header|Clojure}}==
=={{header|Clojure}}==
<lang clojure>(doseq [i (range)] (println (format "%o" i)))</lang>
<lang clojure>(doseq [i (range)] (println (format "%o" i)))</lang>

=={{header|COBOL}}==
{{trans|Delphi}}
{{works with|GNU Cobol|2.0}}
<lang cobol> >>SOURCE FREE
*> Translation of Delphi
IDENTIFICATION DIVISION.
PROGRAM-ID. count-in-octal.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
FUNCTION dec-to-oct
.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 i PIC 9(18).

PROCEDURE DIVISION.
PERFORM VARYING i FROM 1 BY 1 UNTIL i = 0
DISPLAY FUNCTION dec-to-oct(i)
END-PERFORM
.
END PROGRAM count-in-octal.


IDENTIFICATION DIVISION.
FUNCTION-ID. dec-to-oct.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01 rem PIC 9.

01 dec PIC 9(18).

LINKAGE SECTION.
01 dec-arg PIC 9(18).

01 oct PIC 9(18).

PROCEDURE DIVISION USING dec-arg RETURNING oct.
MOVE dec-arg TO dec *> Copy is made to avoid modifying reference arg.
PERFORM WITH TEST AFTER UNTIL dec = 0
MOVE FUNCTION REM(dec, 8) TO rem
STRING rem, oct DELIMITED BY SPACES INTO oct
DIVIDE 8 INTO dec
END-PERFORM
.
END FUNCTION dec-to-oct.</lang>


=={{header|CoffeeScript}}==
=={{header|CoffeeScript}}==
Line 277: Line 326:
n += 1
n += 1
</lang>
</lang>

=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
<lang lisp>(loop for i from 0 do (format t "~o~%" i))</lang>
<lang lisp>(loop for i from 0 do (format t "~o~%" i))</lang>
Line 950: Line 1,000:
=={{header|PL/I}}==
=={{header|PL/I}}==
Version 1:
Version 1:
<lang PL/I>/* Do the actual counting in octal. */
<lang pli>/* Do the actual counting in octal. */
count: procedure options (main);
count: procedure options (main);
declare v(5) fixed(1) static initial ((5)0);
declare v(5) fixed(1) static initial ((5)0);
Line 975: Line 1,025:
end count;</lang>
end count;</lang>
Version 2:
Version 2:
<lang PL/I>count: procedure options (main); /* 12 Jan. 2014 */
<lang pli>count: procedure options (main); /* 12 Jan. 2014 */
declare (i, j) fixed binary;
declare (i, j) fixed binary;


Line 986: Line 1,036:


end count;</lang>
end count;</lang>

Output:
{{out}}
<pre>
<pre>
00000001173
00000001173