Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
22
Task/ISBN13-check-digit/SETL/isbn13-check-digit.setl
Normal file
22
Task/ISBN13-check-digit/SETL/isbn13-check-digit.setl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
program isbn13;
|
||||
loop for test in [
|
||||
"978-0596528126", "978-0596528120",
|
||||
"978-1788399081", "978-1788399083"
|
||||
] do
|
||||
print(test + if valid_isbn13 test then ": good" else ": bad" end);
|
||||
end loop;
|
||||
|
||||
op valid_isbn13(isbn);
|
||||
if #isbn /= 14
|
||||
or isbn(4) /= '-'
|
||||
or exists c in isbn | not c in "0123456789-" then
|
||||
return false;
|
||||
end if;
|
||||
|
||||
m := 3;
|
||||
loop for ch in isbn | ch in "0123456789" do
|
||||
s +:= val ch * (m := 4 - m);
|
||||
end loop;
|
||||
return s mod 10 = 0;
|
||||
end op;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue