供給されるアイテムの量と行数に応じて、特定の量のページを印刷するシステムをセットアップしようとしています。
私は基本的に、いくつかのフィールドを持つマップのリストを持っています。名前フィールドは非常に長く、プリンターでは数行にまたがる可能性があります。何行かかるかを判別できる機能があるので、問題ありません。
主な問題は、別のページを開始できるように、製品のコレクションが 30 行になったときに分割 (clojure の用語を使用する場合はパーティション) したいことです。コレクションを実行して合計ライン数を 30 まで計算し (それ以外の場合は 30 ラインを超える複数ラインの製品がある場合はそれ以下)、それを分割する方法はありますか?
これを回したい
[{:qty 2 :size "M" :product "Testing 1 2 3"}
{:qty 1 :size "S" :product "Hello there world"}
{:qty 12 :size "XS" :product "Some really long product name just to test"}
{:qty 932 :size "L" :product "More longer names to play with"}
{:qty 1 :size "M" :product "Another product name"}
{:qty 1242 :size "XS" :product "This is just an obscenely long product name that I am hoping will spill over on to the next lines"}
{:qty 2 :size "M" :product "Testing 1 2 3"}
{:qty 1 :size "S" :product "Hello there world"}
{:qty 12 :size "XS" :product "Some really long product name just to test"}
{:qty 932 :size "L" :product "More longer names to play with"}
{:qty 1 :size "M" :product "Another product name"}
{:qty 1242 :size "XS" :product "This is just an obscenely long product name that I am hoping will spill over on to the next lines"}
{:qty 2 :size "M" :product "Testing 1 2 3"}
{:qty 1 :size "S" :product "Hello there world"}
{:qty 12 :size "XS" :product "Some really long product name just to test"}
{:qty 932 :size "L" :product "More longer names to play with"}
{:qty 1 :size "M" :product "Another product name"}
{:qty 1242 :size "XS" :product "This is just an obscenely long product name that I am hoping will spill over on to the next lines"}]
これに
[[{:qty 2 :size "M" :product "Testing 1 2 3"}
{:qty 1 :size "S" :product "Hello there world"}
{:qty 12 :size "XS" :product "Some really long product name just to test"}
{:qty 932 :size "L" :product "More longer names to play with"}
{:qty 1 :size "M" :product "Another product name"}
{:qty 1242 :size "XS" :product "This is just an obscenely long product name that I am hoping will spill over on to the next lines"}
{:qty 2 :size "M" :product "Testing 1 2 3"}
{:qty 1 :size "S" :product "Hello there world"}
{:qty 12 :size "XS" :product "Some really long product name just to test"}
{:qty 932 :size "L" :product "More longer names to play with"}
{:qty 1 :size "M" :product "Another product name"}]
[{:qty 1242 :size "XS" :product "This is just an obscenely long product name that I am hoping will spill over on to the next lines"}
{:qty 2 :size "M" :product "Testing 1 2 3"}
{:qty 1 :size "S" :product "Hello there world"}
{:qty 12 :size "XS" :product "Some really long product name just to test"}
{:qty 932 :size "L" :product "More longer names to play with"}
{:qty 1 :size "M" :product "Another product name"}
{:qty 1242 :size "XS" :product "This is just an obscenely long product name that I am hoping will spill over on to the next lines"}]]
商品名の最大行長は 25 文字です
よろしくお願いします!