Stack Exchangeファビコンを生成する


25

PPCGロゴを認識していますか?アスキーアートをすると、こんな感じになります。

+---+
|PCG|
+---+
   v

さて、このコードゴルフでは、PPCGロゴに似た他のサイトのロゴを作成するコードを作成します。

あなたがすべきこと

「短縮」文字列は、入力文字列にすべて大文字と数字を含む文字列になります(PPCG入力文字列がの場合Programming Puzzles & Code Golf)。

ボックス" (

+---+
|   |
+---+
   v

)Shortened stringに完全に適合する必要があります(大きくも小さくもない)。

また、vパーツは正確に1つ下、左から1つ右下にある必要があり+ます。

次に、短縮された文字列を含むボックスを出力します。

例

Stack Overflow:

+--+
|SO|
+--+
  v

Area 51:

+---+
|A51|
+---+
   v

ルール

入力に少なくとも1つの数字または大文字が含まれていると想定することができます。

標準の規則が適用されます。



@MartinEnderはい、非常に密接に関連していますが、重複していません。

1
@MatthewRohリンクの目的は、サイドバーに課題が表示されるようにすることです。そうは言っても、個人的には不要な文字を削除して印刷すること^は、私がリンクした2番目の課題と比べてあまり追加されないと思いますが、その上でデュープハンマーを投げることはありませんが、コミュニッツがそれをデュープと見なすか、ありません。
— マーティンエンダー

4
もしそうだったなら99 Bottles Of Beer、それはそうでしょう99BOB。

1
@MatthewRohはまだバグが多いので、結局bfの答えを得ることができるかどうか見てみましょう
— Rohan Jhunjhunwala

回答:


23

Vim、42ストローク

:s/[^A-Z0-9]//g
YPVr-i+<DOWN><LEFT>|<ESC><C-V>ky$pYjppVr $xrv

交換 <DOWN>と↓、<LEFT>と←、<ESC>とescして<C-V>とCTRL+ V。

以下に、このスクリプトを実行するアニメーションを示します(古いバージョンではを使用しVますv)。

Animation

スクリプトの説明:

:s/[^A-Z0-9]//g                               # Remove all the characters that are not uppercase or numbers using a Regex.
YPVr-                                         # Duplicate the current, and replace all the characters of the upper one with dashes.
     i+<DOWN><LEFT>|<ESC>                     # Insert a + on the upper line, and a | on the second line.
                         <C-V>ky$p            # Copy the + and | to the end of both lines.
                                  Yjpp        # Copy the upper line to the bottom two times.
                                      Vr $    # Replace the bottom most line with spaces and put the cursor on the last character.
                                          xrv # Remove the last character and replace the second last character with a v.

大文字Vではなく小文字V

もう1文字ですが、特殊なエスケープ文字を避けます:r | y uP $ pYPVr-r + $。YjppVr $ hrV
— ブライスワーグナー

を置き換えi+↓←|␛␖ky$pてA+↓|␛␖ky0Pバイトを保存できます。
— リン

代わりに、とブライスのアプローチでは最初の8つのストロークを置き換えるI|<END>|␛
— リン・

クールな写真のために、これが最も賛成票を持っているのだろうか。
— ジョー

10

V 34バイト

Ó[^A-Z0-9]
ys$|ÄVr-r+$.YLppVr x$rv

これは古いバージョンでは機能しましたが、オンラインで試してみると現在のバージョンでは機能しないことに注意してください。機能的に同等なものに変更ÄしましYPた。

オンラインでお試しください!

説明:

Ó[^A-Z0-9]

数字と大文字を除くすべてを削除します。

ys$|              "Surround this line with '|' characters.
    Ä             "Duplicate this line
     Vr-          "Replace this whole duplicated line with '-' characters
        r+        "replace the first character with '+'
          $       "Move to the end of the line, and
           .      "Repeat our last command. This is the same as 'r+'
            Y     "Yank the current line
              pp  "and paste it twice
             L    "At the end of our text

これで、バッファは次のようになります。

+---+
|A51|
+---+
+---+

そして、カーソルは最後の行の最初の列にあります。

Vr                 "Change the whole last line to spaces
   x               "Delete a character
    $rv            "And change the last character to a 'v'

非競合バージョン:(31バイト)


入力で出力にProgramming Puzzles & Code Golf誤った文字列PP&CGが生成されることに気付きました。&除去しなければならない
— ルイス・Mendo

@LuisMendo Aww、やった!それを指摘してくれてありがとう、私は今日いつかそれを修正します。
— DJMcMayhem

@DrGreenEg​​gsandIronManそれで、あなたはそれを修正しましたよね?[いつ?意志?君は?最後に?修正しますか?それ?]
— エリック・ザ・アウトゴルファー

TIOに出力がありませんか?
— ダウンゴート

@Downgoat Vには最近大きなアップデートがありましたが、残念ながらそれは私が検討しているいくつかの事柄を中断しましたが、修正にどれくらいかかるかわかりません。
— DJMcMayhem

7

16ビットx86マシンコード、72バイト

16進数で:

565789F731C9FCAC84C074143C5A77F73C4173083C3977EF3C3072EBAA41EBE75F5EE81500B07CAA51F3A4AB59E80A00B020F3AAB076AA91AAC351B02BAAB02DF3AAB82B10AB59C3

パラメータ:SI=入力文字列DI-出力バッファ。

改行で区切られた行でNULLで終わる文字列を出力します。入力文字列を一時バッファとして使用します。

56           push   si
57           push   di
89 f7        mov    di,si    ;Using source string as a buffer
31 c9        xor    cx,cx    ;Counter
fc           cld
_loop:
ac           lodsb
84 c0        test   al,al    ;Test for NULL
74 14        jz     _draw    ;Break
3c 5a        cmp    al,'z'   ;\
77 f7        ja     _loop    ; |
3c 41        cmp    al,'a'    ; \
73 08        jae    _stor    ;  >[A-Z0-9]?
3c 39        cmp    al,'9'   ; /
77 ef        ja     _loop    ; |
3c 30        cmp    al,'0'   ;/
72 eb        jb     _loop
_stor:
aa           stosb           ;Store char in the source buffer
41           inc    cx
eb e7        jmp    _loop
_draw:
5f           pop    di
5e           pop    si
e8 15 00     call   _line    ;Output the first line
b0 7c        mov    al,'|'   ;This proc upon return leaves '\n' in AH
aa           stosb           ;First char of the second line
51           push   cx
f3 a4        rep    movsb    ;Copy CX logo characters from the source buffer
ab           stosw           ;Outputs "|\n", which is still in AX
59           pop    cx
e8 0a 00     call   _line    ;Output the third line
b0 20        mov    al,0x20  ;Space
f3 aa        rep    stosb    ;Output it CX times
b0 76        mov    al,'v'
aa           stosb           ;Output the final 'v'
91           xchg   cx,ax    ;CX == 0
aa           stosb           ;NULL-terminate the string
c3           retn            ;Return to caller
_line:
51           push   cx
b0 2b        mov    al,'+'
aa           stosb
b0 2d        mov    al,'-'
f3 aa        rep    stosb     ;'-'*CX
b8 2b 10     mov    ax,0x102b ;"+\n"
ab           stosw
59           pop    cx
c3           retn

Uhh ..しばらくの間アセンブリコードを実行していません。

3
私も。約1週間前にゴルフのみのために再び開始
— -meden

3c 41 cmp al,a' そうではありません3c 41 cmp al,'a' か?
— rav_kr

@rav_kr、確かに、気づいてくれてありがとう。読みやすくするために、16進コードを文字に置き換えているときに引用符を逃しました。
— meden

4

網膜、43バイト

[^A-Z\d]

.+
+$.&$*-+¶|$&|¶+$.&$*-+¶$.&$* V

オンラインでお試しください!

これは、マーティン・エンダーのゴルフ言語であるRetinaを実証するための完璧な挑戦です。

このソリューションは2つのステップ(私たちがステージと呼んでいるもの)に分けられ、両方のステージは置換ステージです。

最初の段階:

[^ AZ \ d]

これは、一致する部分文字列と一致します [^A-Z\d]は、大文字でも数字でもない文字であり、何も置き換えない、つまり削除することを意味します。

第二段階:

.+
+$.&$*-+¶|$&|¶+$.&$*-+¶$.&$* V

の .+全体の結果と一致し、その後、二行目でそれを置換します。

2行目:

  • $& マッチ全体を指します
  • $.& マッチ全体の長さを指します
  • $*は、前の整数を取得し、次の文字を何回も繰り返すことを意味します。ここで$.&$*-は-、試合がどれだけ長くても繰り返すことを意味します。
  • 改行を指します。

いいですね、私は以前にこれを試しましたが、結局54バイトになりました。第一段階の代替案はT`dLp`dL_、残念ながら同じ長さです。
— マーティンエンダー

@MartinEnderあなたの54バイトは何でしたか?
— リーキー修道女


4

C#、183177165バイト

string h(string s){s=string.Concat(s.Where(n=>n>47&n<58|n>64 &n<91));int m=s.Length;var x=new string('-',m);return$"+{x}+\n|{s}|\n+{x}+\n{new string(' ', m + 1)}v";}

C#ではcharsの乗算はひどいです。提案に感謝

-18バイトのaloisdgに感謝します


置き換えることができます| |と|
— aloisdgは回復モニカ言う

あなたは、文字列の補間を使用することができますreturn$"+{x}+\n|{s}|\n+{x}+\n{new string(' ',m+1)}v";}
— aloisdgは回復モニカ言う

1
それは甘い方法です!
— downrep_nation

置き換えることができますstring.Join("", とstring.Concat(
— aloisdgは回復モニカ言う

1
あなたが後にスペースを削除することができますreturn
— aloisdgは回復モニカ言う

4

Excel VBA、375 359 358バイト:

それはうまくいきます、私はそれを短くしようとしてあきらめます...

編集:ifステートメントからcaseステートメントに切り替え、-16バイト

Edit2:uを取り除き、Len(b)、-1バイトに置き換えました

Function b(x)
For i = 1 To Len(x)
a = Mid(x, i, 1)
e = Asc(a)
If e > 64 And e < 91 Or e > 47 And e < 58 Then b = b & a
Next i
For Z = 1 To 4
y = ""
Select Case Z
Case 2
y = "|" & b & "|"
Case 4
For i = 1 To Len(b)
y = y & " "
Next i
y = y & "v"
Case Else
y = "+"
For i = 1 To Len(b)
y = y & "-"
Next i
y = y & "+"
End Select
Debug.Print y
Next Z
End Function

3
ただし、VBAが時々ゴミになることを考えると、良いことです。

私はチャレンジのためだけにこれらを行います。VBAと競争することはできません。通常、すべての変数を名前から単一の文字に変更した後、最後に非常に混乱します。
— tjb1

そうそうikrそうです

演算子の周りの空白を削除できますか?
— モーガンスラップ16

3
「Got rid of u」で笑った
— CocoaBean

4

Lua、145 99バイト

言うまでもありませんが、文字列の操作はluaでは常に冗長です:)。コマンドライン引数を取り、STDOUTを介して出力します

45バイト節約してくれた@LeakyNunに感謝します!

n=(...):gsub("[^%u%d]","")s="+"..("-"):rep(#n).."+\n"return s.."|"..n.."|\n"..s..(" "):rep(#n).."V"

@LeakyNunが提案した100バイト

n=(...):gsub("[^A-Z%d]","")s="+"..("-"):rep(#n).."+\n"return s.."|"..n.."|\n"..s..(" "):rep(#n).."V"

OLD 145バイト

g="|"..(...):gsub("%a+",function(w)return w:sub(1,1)end):gsub("%s",'').."|"S="+"..g.rep("-",#g-2).."+"p=print
p(S)p(g)p(S)p(g.rep(" ",#g-2).."v")

非ゴルフ

g="|"                            -- g is the second, and starts with a |
  ..(...):gsub("%a+",            -- append the string resulting of the iteration on each word
    function(w)                  -- in the input, applying an anonymous function
      return w:sub(1,1)          -- that return the first character of the word
    end):gsub("%s",'')           -- then remove all spaces
  .."|"                          -- and append a |
S="+"..g.rep("-",#g-2).."+"      -- construct the top and bot of the box
p=print                          -- alias for print
p(S)p(g)p(S)                     -- output the box
p(g.rep(" ",#g-2).."v")          -- output #g-2 spaces (size of the shortened name), then v

1
ええと、STDOUTを介した出力ですか?しかし、私は反対の日!!!

1
@MatthewRoh私はあなたの端末のSTDINに出力することを意味しました!(修正...恥....)
— Katenkyo

n=(...):gsub("[^A-Z%d]","")s="+"..("-"):rep(#n).."+\n"return s.."|"..n.."|\n"..s..(" "):rep(#n).."V"100バイトである
— 漏れ修道女

@LeakyNunパターン%uを使用して、さらにバイトを増やします。とにかく、ありがとう:)(後でゴルファーを更新します)
— かてんきょう

3

2sable、36 34 33 32 31バイト

2sableの提示:)。05AB1Eと多くの共通点がありますが、実際にはスタックの最上部を出力するのではなく、スタックに自動的に参加します。コード:

žKA-ég'-×'+DŠJDU„
|®sX¶®gð×'v

CP-1252エンコードを使用します。


2
ಠ_ಠゴルフや言語の切り替えはもうありません!現在の場所に残してください!:P
— DJMcMayhem

@DrGreenEg​​gsandIronManハハハ、それはあなたの答えからまだ痛みを伴う 3 バイトです:P。
— アドナン

1
ハハ、私は...一つ一つ、私は7バイトより長く、それを見たときに祝って、その後、ゆっくりとギャップが消えて見た
— DJMcMayhem

3

JavaScript(ES6)、99バイト

(s,t=s.replace(/[^0-9A-Z]/g,``),g=c=>t.replace(/./g,c))=>`${s=`+${g(`-`)}+
`}|${t}|
${s}${g(` `))v`

3

Haskell、107バイト

この回答を重くすることによって回答に基づいているZylviijとのコメントnimi。私はその答えにさらにコメントを追加したでしょうが、残念ながら、私は十分な担当者を持っていません。

o n=t++'|':f++"|\n"++t++(f>>" ")++"v"where f=[c|c<-n,any(==c)$['0'..'9']++['A'..'Z']];t='+':(f>>"-")++"+\n"

使用される追加のトリック:

  • 交換済み intersect実装をため、インポートを削除できます。(補足:実装はライブラリのものとほぼ同じです。短いバージョンは見つかりませんでした。)
  • where関数が使用できるように、ヘルパー関数を句に移動しましたnパラメーターを内部で。
  • その後、 (#)インライン化できるほど短かった。
  • 余分な空白を制限するために、すべてを1行に入れてください。

2

Python 3.5、114 93 112バイト:

import re;Y=re.findall('[A-Z0-9]',input());I='+'+'-'*len(Y)+'+\n|';print(I+''.join(Y)+I[::-1]+'\n'+' '*len(Y)+'v')

完全なプログラム。基本的に正規表現を使用して、大文字と数字のすべての出現を照合し、一致リストの長さに基づいて正確なサイズのボックスを作成し、最後に結合リストを「内部」に配置します。

オンラインでお試しください!(イデオン)


5
下の「v」がありません。
— カールズ社

@CarlesCompany固定されていますが、コストはさらに19バイトです。
— R.ガプス

2

Python 3、121 124バイト

愚かな間違いを修正

s=''
for i in input():_=ord(i);s+=("",i)[91>_>64or 47<_<58]
x=len(s)
c='+'+"-"*x+'+'
print(c+"\n|"+s+"|\n"+c+"\n"+" "*x+"v")

他のPythonの答えのようなライブラリをインポートしません。



@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ修正済み。ありがとう
— 破壊可能なレモン

実際には、リンクはいくつかのコードをたたいていたので、そこに置いたのです。
— エリックアウトゴルファー16

2

Java 8、149バイト

s->{s=s.replaceAll("[^A-Z0-9]","");String t="+",r;int l=s.length(),i=l;for(;i-->0;t+="-");for(r=(t+="+\n")+"|"+s+"|\n"+t;++i<l;r+=" ");return r+"v";}

オンラインでお試しください。

説明:

s->{                     // Method with String as both parameter and return-type
  s=s.replaceAll("[^A-Z0-9]","");
                         //  Leave only the uppercase letters and digits
  String t="+",          //  Temp-String, starting at "+"
         r;              //  Result-String
  int l=s.length(),      //  Amount of uppercase letters and digits `l`
  i=l;for(;i-->0;t+="-");//  Loop and append `l` amount of "-" to the temp-String
  for(r=(t+="+\n")       //  Append "+" and a new-line to the temp-String
        +"|"+s+"|\n"+t;  //  Set the result to `t`, "|", modified input, "|", new-line, `t`
                         //  all appended to each other
      ++i<l;r+=" ");     //  Loop and append `l` amount of spaces to the result
  return r+"v";}         //  Return the result-String with appended "v"



1

Python 2、113バイト

def f(n):c=filter(lambda x:x.isupper()^x.isdigit(),n);L=len(c);h='+'+L*'-'+'+\n';return h+'|'+c+'|\n'+h+' '*L+'v'

Pythonでasciiを使用できますか?はいの場合、使用できます47<x<58|64<x<91:)
— aloisdgは、Reinstate Monica

@aloisdg C / C ++とは異なり、Pythonは整数char型を使用しません。Python 文字列のすべての文字はそれ自体が文字列であり、整数と直接比較することはできません。それが必要になるでしょう47<ord(x)<58or 64<ord(x)<91。
— メゴ

[x for x in n if x.isupper()^x.isdigit()]より1バイト短いですfilter(lambda x:x.isupper()^x.isdigit(),n)
— 漏れ修道女

@LeakyNun: filter will return a string, but the list comprehension will return a list, which won't be usable in the return value expression.
— Nikita Borisov

Why XOR? Can't you use OR instead? XOR is more complex, and thus slower AFAIK. x.isupper()^x.isdigit() -> x.isupper()|x.isdigit()
— Erik the Outgolfer

1

Jolf, 35 bytes

Ά+,Alγ/x"[^A-Z0-9]"1'+'-'|γS*lγ" 'v

I need a shorter way to remove all but caps & numbers...


1

C, 171 163

Function f() modifies its input and prints out the result.

l;f(char*n){char*p=n,*s=n,c[99];for(;*n;++n)isupper(*n)+isdigit(*n)?*p++=*n:0;*p=0;memset(c,45,l=strlen(s));c[l]=0;printf("+%s+\n|%s|\n+%s+\n%*.cv\n",c,s,c,l,32);}

Test Program

Requires one parameter, the string to use in the favicon:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(int argc, const char **argv)
{
    char *input=malloc(strlen(argv[1])+1);
    strcpy(input,argv[1]);
    f(input);
    free(input);
    return 0;
}

Why do you copy the argv element?
— mame98

Because the function modifies its input. I'm not sure modifying the parameters in place is defined behavior.
— owacoder

never thought about this... according to this SO answer it should be fine: stackoverflow.com/a/963504/3700391
— mame98

1

Haskell, 161

import Data.List
r=replicate
l=length
f n=intersect n$['0'..'9']++['A'..'Z']
t n='+':(r(l$f n)'-')++"+\n"
o n=(t n)++"|"++(f n)++"|\n"++(t n)++(r(l$f n)' ')++"V"

Usage

o"Stack Overflow"
+--+
|SO|
+--+
  V

o"Area 51"
+---+
|A51|
+---+
   V

1
You're using replicate, length and f exclusively in this combination, so you can merge them into one function: r=replicate.length.f and call it like r n '-'. You can save even more bytes by using an infix operator: (#)=replicate.length.f and n#'-' / n#' '. Additionally replicate.length is >> (with a singleton string instead of a char), so it's: (#)=(>>).f and n#"-" / n#" ", both without ( ) around it.
— nimi

1
... also: no need for the ( ) around t n and f n. "|"++ is '|':. All in all: o n=t n++'|':f n++"|\n"++t n++n#" "++"V".
— nimi

1

Bash, 99 74 bytes

s=$(sed s/[^A-Z0-9]//g);a=${s//?/-};echo -e "+$a+\n|$s|\n+$a+\n${s//?/ }v"

Usage: Run the above command, type the site name, press enter and then Ctrl + D (send 'end of file').



1

R, 108 bytes

cat(x<-gsub("(.*)","+\\1+\n",gsub(".","-",y<-gsub("[^A-Z0-9]","",s))),"|",y,"|\n",x,gsub("."," ",y),"v",sep="")

Explanation

Going from the inside out (because who doesn't love assigning global variables from inside a regex), assuming s is our input string:

y<-gsub("[^A-Z0-9]","",s) keeps capitals and numbers, assigns the resulting value to y.

gsub(".","-",y<-...) replaces all characters with hyphens in the above.

x<-gsub("(.*)","+\\1+\n",gsub(...)) chucks a + on either end of the row of hyphens, and a newline, and we store that as x.

The rest is pretty straightforward, output in the appropriate order, and use the fact that the number of spaces before the v will be the same as the length of y.


1

Brachylog, 61 bytes

Linked to the repository at Jul 7 to ensure backward compatibility.

lybL:{,."-"}ac:"+"c:"+"rcAw@NNw"|"Bw?wBwNwAwNwL:{," "w}a,"v"w

Non-competing, 53 bytes

lL:"-"rjb:"+"c:"+"rcAw@NNw"|"Bw?wBwNwAwNw" ":Ljbw"v"w

Try it online!


1

APL, 52 49 bytes

{x⍪2⌽'v'↑⍨≢⍉x←⍉z⍪⍨(z←'+|+')⍪'-','-',⍨⍪⍵/⍨⍵∊⎕D,⎕A}

(down to 49 thanks to the comment).


{x⍪2⌽'v'↑⍨≢⍉x←⍉z⍪⍨(z←'+|+')⍪'-','-',⍨⍪⍵/⍨⍵∊⎕D,⎕A} (You never parenthesize one of the arguents in a reversed argument function when golfing. It always can be in normal order to save a byte.)
— Zacharý

1

Perl, 57 bytes

56 bytes code + 1 for -p.

y/a-z //d;$d="-"x y///c;$_="+$d+
|$_|
+$d+
".$"x y///c.v

I originally tried to make this only using regexes, but it was much larger than I'd hoped, so I've used some string repetition instead.

Try it online!


1

MATL, 34 bytes

t1Y24Y2hm)T45&Ya'+|+'!wy&h10M~'v'h

Try it online!

t        % Implicit input. Duplicate
1Y2      % Uppercase letters
4Y2      % Digit characters
h        % Concatenate horizontally: string with uppercase letters and digits
m        % True for input chars that are uppercase letters or digits
)        % Keep only those
T45&Ya   % Pad up and down with character 45, which is '-'. Gives three-row char array
'+|+'!   % Push this string and transpose into a column vector
wy       % Swap, duplicate the second array from the top. This places one copy of the
         % column vector below and one above the three-row char array
&h       % Contatenate all stack arrays horizontally. This gives the box with the text
10M      % Retrieve the string with selected letters
~        % Logical negate. Gives zeros, which will be displayes as spaces
'v'      % Push this character
h        % Concatenate horizontally with the zeros.
         % Implicitly display the box with the text followed by the string containing
         % the zero character repeated and the 'v'

1

JavaScript (ES6), 119 bytes

h=a=>"+"+"-".repeat(a.length)+"+\n";j=a=>(a=a.replace(/[^A-Z0-9]/g,""),h(a)+"|"+a+"|\n"+h(a)+" ".repeat(a.length)+"v");

1

J, 52 bytes

'v'(<3 _2)}4{.1":]<@#~2|'/9@Z'&I.[9!:7@'+++++++++|-'

Try it online!

   [9!:7@'+++++++++|-'            Set the box drawing characters.
        '/9@Z'&I.                 Interval index, 1 for numbers, 3 for 
                                  uppercase letters.
          ]  #~2|                 Mod 2, and filter
                                  the characters that correspond to 1s.
           <@                     Put them in a box.
           1":                    Convert to a character matrix, so we can do stuff to it.
           4{.                    Add a 4th line filled with spaces   
       'v'(<3 _2)}                Insert a “v” at 3,−2

0

Ruby, 81 bytes (78 + -p flag)

gsub(/[^A-Z\d]/,'')
gsub(/.+/){"+#{k=?-*s=$&.size}+
|#{$&}|
+#{k}+
#{' '*s}v"}

0

Common Lisp (Lispworks), 159 bytes bytes

(defun f(s)(labels((p(c l)(dotimes(i l)(format t"~A"c))))(let((l(length s)))#1=(p"+"1)#2=(p"-"l)#3=(format t"+~%")(format t"|~A|~%"s)#1##2##3#(p" "l)(p"v"1))))

ungolfed:

(defun f (s)
  (labels ((p (c l)
             (dotimes (i l)
               (format t "~A" c))))
    (let ((l (length s)))
      #1=(p "+" 1)
      #2=(p "-" l)
      #3=(format t "+~%")
      (format t "|~A|~%" s)
      #1#
      #2#
      #3#
      (p " " l)
      (p "v" 1))))

Usage:

CL-USER 2 > (f "so")
+--+
|so|
+--+
  v
NIL

CL-USER 3 > (f "pcg")
+---+
|pcg|
+---+
   v
NIL
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.