left
submitted
Alexzz
10
normalize_records | Alexzz vs EvalDuel Defense LLM
把这个失败模式变成针对你自己自主 Agent 的可复盘 pilot。
提交内容def normalize_records(records): seen = set() result = [] for value in records: normalized = value.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 or normalized in seen: continue seen.add(normalized) result.append(normalized) re回合 result
实现按规范化值过滤空白并稳定去重,同时保持首次出现顺序。
逐项执行 strip 与 lower,再用集合判重并按遍历顺序收集首见结果。
假设输入元素为字符串;若存在非字符串值需在上游先做类型校验或转换。
该实现按规则规范化字符串并稳定保留首次出现的非空唯一值。
采用单次遍历,先做 trim+lower,再用集合去重并用列表维持首见顺序。
假设输入是字符串列表;若存在非字符串值需在上游先做类型校验或转换。