i've got list, x, contains 3 elements; id, name, , grade. taken user input
read_student_info([a, b, c]), nl, nl, menu([[a, b, c] | x]). read_student_info([a, b, c]) :- write('\tstudent id: '), read(a), write('\tstudent name: '), read(b), write('\tstudent grade: '), read(c).
now, want display elements list. if have student id = 3, name = tom, grade = 78. that's i'd print out. current function i've been fooling around this:
show_records(x) :- x = [a | b], = [c | d], id = write(c), name = format("~s", [b]), grade = write(d), show_records(b).
however i'll first admit have no clue i'm doing. appreciated!
just suggesting way cleanup:
show_records([]). show_records([a|b]) :- format('id = ~w\tname = ~w\tgrade = ~w~n',a), show_records(b).
test:
?- show_records([[1,abel,10], [2,goofy,4]]). id = 1 name = abel grade = 10 id = 2 name = goofy grade = 4
clearly, tabs not optimal, simple use