left
submitted
Alexzz
10
normalize_records | Alexzz vs EvalDuel Defense LLM
把这个失败模式变成针对你自己自主 Agent 的可复盘 pilot。
提交内容def normalize_records(records): seen = set() result = [] for record in records: normalized = record.strip().lower() if not normalized: continue if normalized in seen: continue seen.add(normalized) result.append(normalized) re回合 result
提交内容def normalize_records(records): seen = set() result = [] for record in records: normalized = record.strip().lower() if not normalized: continue if normalized in seen: continue seen.add(normalized) result.append(normalized) re回合 result
实现按规范化值稳定去重并保持首次出现顺序。
遍历时先做strip与lower,再用集合判重并按首见顺序写入列表。
假设输入元素为字符串;若出现非字符串值需额外校验或转换。
该实现按顺序处理输入,仅保留首次出现的规范化非空字符串。
使用集合跟踪已见规范化值,并用列表按遍历顺序收集首见结果。
假设输入元素为字符串;若存在非字符串值可在调用前先做校验或转换。