HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📌
hkob's Notion
/
ℹ️
逆引きFormula 2.0
/
💾
Database storage
/
重複したものを探すには?

重複したものを探すには?

Status
Created by 2.0
関数説明
属性名
Duplicate?
返り値
List
関連するもの
ℹ️
逆引きFormula 2.0
に戻る
重複したものを探したい時にどうすればいいかという質問があったので、思いつきで作ってみました。自分より後ろに同じものがある場合に重複と判定するようにしています。map の中で index を保持しておきたいため、lets で別の変数に置き換えるテクニックを使っています。
  1. 数値のリストの場合
 
Duplicate check
名前
list
duplicate
num1
num2
num3
num4
重複なし
123
456
789
12
一つだけ重複
5
7
5
8
重複ペア
1
2
1
2
3つある
100
10
100
100
全て重複
5
5
5
5
 
prop("list").map( lets( map_index, index, map_current, current, find_index, prop("list").filter(index > map_index) .findIndex(current == map_current), find_index == -1 ? "".toNumber() : map_current ) )