2 added 135 characters in body

(a#b)n=af[a,b]n=a:(b<$[3..n])++[a] i%j=unlines$(('|'#'g i=unlines.f[f"|-')i#('|'#'"i,f"| ')i)j"i]


Usage example:

*Main> putStr $10%3g 10 3 |--------| | | |--------|  The helper function #f takes three arguments, a,a two element list b[a,b] and a number n, makes and returns a list of one a followed by n-2 bs followed by one a. We can use #f thrice: to build the top/bottom line: ('|'#'f "|-')" i, a middle line: ('|'#'f ')"| " i and from those two the whole rectangle: (<top>#<middle>)f [<top>,<middle>] j (note: j doesn't appear as a parameter in g i because of partial application). Edit: @dianne saved some bytes by combining two Char arguments into one String of length 2. Thanks a lot! ## Haskell, 62 bytes (a#b)n=a:(b<$[3..n])++[a]
i%j=unlines$(('|'#'-')i#('|'#' ')i)j  Usage example: *Main> putStr$ 10%3
|--------|
|        |
|--------|


The helper function # takes three arguments, a, b and n, makes a list of one a followed by n-2 bs followed by a. We can use # thrice: to build the top/bottom line: ('|'#'-')i, a middle line: ('|'#' ')i and from those two the whole rectangle: (<top>#<middle>)j.

f[a,b]n=a:(b<$[3..n])++[a] g i=unlines.f[f"|-"i,f"| "i]  Usage example: *Main> putStr$ g 10 3
|--------|
|        |
|--------|


The helper function f takes a two element list [a,b] and a number n and returns a list of one a followed by n-2 bs followed by one a. We can use f thrice: to build the top/bottom line: f "|-" i, a middle line: f "| " i and from those two the whole rectangle: f [<top>,<middle>] j (note: j doesn't appear as a parameter in g i because of partial application).

Edit: @dianne saved some bytes by combining two Char arguments into one String of length 2. Thanks a lot!

1

(a#b)n=a:(b<$[3..n])++[a] i%j=unlines$(('|'#'-')i#('|'#' ')i)j

*Main> putStr \$ 10%3

The helper function # takes three arguments, a, b and n, makes a list of one a followed by n-2 bs followed by a. We can use # thrice: to build the top/bottom line: ('|'#'-')i, a middle line: ('|'#' ')i and from those two the whole rectangle: (<top>#<middle>)j.