0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SATySFiでリストを書く・連結する・分割する

Posted at
@require: stdja

let-inline ctx \unwrap joint =
  match joint with
    % matchで分割できる
    | weed :: paper :: [] -> read-inline ctx (embed-string (weed ^ `と` ^ paper))
    | _ -> read-inline ctx (embed-string `ここに到達することはない`)

let-inline ctx \smoke joint =
  % letでも分割できる
  let (weed :: paper :: []) = joint in
  read-inline ctx (embed-string (`火のついた` ^ weed ^ `と` ^ paper))
in

document (|
  author = { Seiei MIYAGI };
  show-title = true;
  show-toc = false;
  title = { SATySFiでリストを書く・連結する・分割する }
|) '<
  +p {
    % 角括弧の中に要素を書く、各要素は;で区切る
    \unwrap([`草`; `紙`]);
    は
    % ::を使うとリストに要素を連結できる、[]は空リスト
    \unwrap(`草` :: `紙` :: []);
    と同じ
  }
  +p {
    \smoke([`草`; `紙`]);
  }
>

実行結果

Screenshot from 2018-10-22 08-32-49.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?