kid named finger

This commit is contained in:
array-in-a-matrix 2022-11-17 20:44:33 -05:00
parent 5bc5e85110
commit eae5c23730
2 changed files with 32 additions and 12 deletions

View file

@ -4,16 +4,20 @@ DOC_DIR := doc/
DOC_TYPE ?= doc
all:
nim compile --out:$(BUILD_DIR) $(SRC_DIR)*.nim
nim compile --out:$(BUILD_DIR) $(SRC_DIR)*.nim
doc:
nim $(DOC_TYPE) --outdir:$(DOC_DIR) $(SRC_DIR)*.nim
release:
release: clean
nim compile --define:release --out:$(BUILD_DIR) $(SRC_DIR)*.nim
run:
@$(BUILD_DIR)main
run: all
@echo "===================================================="
@echo ""
@$(BUILD_DIR)main
crun: clean run
clean:
@rm -rf $(BUILD_DIR) $(DOC_DIR)

View file

@ -1,12 +1,28 @@
## This module is a sample.
import strutils, sequtils #, strformat
import strutils
proc print_matrix(matrix: seq[seq[float]], row: int) =
for i in countup(1, row):
echo matrix[i-1]
proc helloWorld*(times: int) =
## Takes an integer and outputs
## as many indented "hello world!"s
proc fill_matrix(matrix: var seq[seq[float]], row, col: int) =
for i in countup(1, row):
for j in countup(1, col):
echo "Enter item in row:"
var entry: float = parseFloat(readLine(stdin))
matrix[i-1].add(entry)
matrix[i-1].delete(0)
echo matrix[i-1]
for i in 0 .. times-1:
echo "hello world!".indent(2) # using indent to avoid `UnusedImport`
echo "Enter number of rows:"
let row: int = parseInt(readLine(stdin))
helloWorld(5)
echo "Enter number of columns:"
let col: int = parseInt(readLine(stdin))
var matrix = newSeqWith(row, newSeq[float](col))
fill_matrix(matrix, row, col)
echo "\nMatrix entered is:"
print_matrix(matrix, row)