Sha256: 4504a3fe87a858e125331b995366f42e7fc32ef00ed059e158cb50af3cf720ef

Contents?: true

Size: 346 Bytes

Versions: 10

Compression:

Stored size: 346 Bytes

Contents

Because of the particular nature of M4, the only user-input is the code itself. Anyway the following code can be used:
eval(A+B)
eval(A-B)
eval(A*B)
eval(A/B)
eval(A%B)

once saved in a file, e.g. <tt>operations.m4</tt>:

m4 -DA=4 -DB=6 operations.m4

or using a sort of ''driver'':

define(`A', 4)dnl
define(`B', 6)dnl
include(`operations.m4')

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/m4.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/m4.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/m4.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/m4.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/m4.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/m4.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/m4.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/m4.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/m4.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/m4.txt