Pure Programmer
Blue Matrix


Cluster Map

Project: Punchcard Filter

Write a filter program that converts an input stream into a representation similar to old-style punchcards. Eight rows will be output with 77 columns. Each column in the output representing the bit pattern for one byte in the message. The least significant bit should be at the bottom and the most significant bit should be at the top. Use the LEFT HALF BLOCK Unicode character ('\u258c') to represent a bit that is on in the byte. Use a space for bits that are off. Use other box drawing characters to make the outline of a card around each group of 78 characters

See: [[Punched card]]

Output
$ rustc PunchcardFilter.rs error[E0530]: function parameters cannot shadow statics --> PunchcardFilter.rs:20:17 | 18 | static mut first:bool = true; | ----------------------------- the static `first` is defined here 19 | 20 | fn printDivider(first:bool, last:bool) -> () { | ^^^^^ cannot be named the same as a static error[E0412]: cannot find type `usuze` in this scope --> PunchcardFilter.rs:44:22 | 44 | mask = ((mask) as usuze >> 1) as isize; | ^^^^^ help: a builtin type with a similar name exists: `usize` warning: unnecessary parentheses around block return value --> PunchcardFilter.rs:21:45 | 21 | print!("{}", (if first { TOP_LEFT } else { (if last { BOTTOM_LEFT } else { LEFT_TEE }) })); | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 21 - print!("{}", (if first { TOP_LEFT } else { (if last { BOTTOM_LEFT } else { LEFT_TEE }) })); 21 + print!("{}", (if first { TOP_LEFT } else { if last { BOTTOM_LEFT } else { LEFT_TEE } })); | warning: unnecessary parentheses around block return value --> PunchcardFilter.rs:29:48 | 29 | println!("{}", (if first { TOP_RIGHT } else { (if last { BOTTOM_RIGHT } else { RIGHT_TEE }) })); | ^ ^ | help: remove these parentheses | 29 - println!("{}", (if first { TOP_RIGHT } else { (if last { BOTTOM_RIGHT } else { RIGHT_TEE }) })); 29 + println!("{}", (if first { TOP_RIGHT } else { if last { BOTTOM_RIGHT } else { RIGHT_TEE } })); | error[E0423]: expected function, found builtin type `u32` --> PunchcardFilter.rs:40:23 | 40 | let c2:char = if (u32(c) & mask) != 0 { LEFT_HALF_BLOCK } else { ' ' }; | ^^^ not a function error[E0425]: cannot find function `getcodepoint` in this scope --> PunchcardFilter.rs:53:8 | 53 | while getcodepoint(c) { | ^^^^^^^^^^^^ not found in this scope error[E0308]: mismatched types --> PunchcardFilter.rs:54:23 | 54 | s += char::from_u32(c); | -------------- ^ expected `u32`, found `i32` | | | arguments to this function are incorrect | note: associated function defined here --> /opt/local/libexec/rust/src/rustc-1.71.1-src/library/core/src/char/methods.rs:139:18 help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit | 54 | s += char::from_u32(c.try_into().unwrap()); | ++++++++++++++++++++ error[E0368]: binary assignment operation `+=` cannot be applied to type `&str` --> PunchcardFilter.rs:54:3 | 54 | s += char::from_u32(c); | -^^^^^^^^^^^^^^^^^^^^^ | | | cannot use `+=` on type `&str` error[E0425]: cannot find function `strlen` in this scope --> PunchcardFilter.rs:62:5 | 62 | if strlen(s) > 0 { | ^^^^^^ not found in this scope error[E0425]: cannot find function `strlen` in this scope --> PunchcardFilter.rs:64:23 | 64 | let mut i_:isize = strlen(s); | ^^^^^^ not found in this scope error[E0368]: binary assignment operation `+=` cannot be applied to type `&str` --> PunchcardFilter.rs:66:5 | 66 | s += '\u{0}'; | -^^^^^^^^^^^ | | | cannot use `+=` on type `&str` error: aborting due to 9 previous errors; 2 warnings emitted Some errors have detailed explanations: E0308, E0368, E0412, E0423, E0425, E0530. For more information about an error, try `rustc --explain E0308`.

Solution