我有这个元组列表:
na
我需要提取包含denomination_flexible_denomination 239的元组。有人知道怎么做吗?
答案 0 :(得分:3)
使用lists:keyfind/3
。它的参数是键(在本例中为239),元组中的位置(2,因为它是第二个元组元素),以及元组列表:
C:\Users\Ahmed\Documents\NetBeansProjects\TestWeb\nbproject\build-impl.xml:1045: Deployment error: Starting of Tomcat failed.
See the server log for details.
如果没有匹配的元素,<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
会返回> lists:keyfind(239, 2, TupleList).
{denomination_flexible_denomination,239,8,2,"2",
"CORE BALANCE",0,10,"1","500","100","100",null,
"ecrlrlep_facilito","ecrlrlep_facilito","true",
"[{codigo_producto, \"0010701020\"}, {tipo_trx_pago, \"10120\"}, {tipo_trx_consulta, \"310120\"}, {payment_type, \"electronic_money\"}]"}
。
答案 1 :(得分:0)
<a href="/my/action">Name</a>
答案 2 :(得分:0)
1> L = [{denomination_flexible_denomination,236,9,2,"1","CORE BALANCE",0,10,"1","500","100","100",null,"ecrlrlep_facilito","ecrlrlep_facilito","true","[{codigo_producto, \"0010701020\"}, {tipo_trx_pago, \"10220\"}, {tipo_trx_consulta, \"310220\"}, {payment_type, \"electronic_money\"}]"},
1> {denomination_flexible_denomination,239,8,2,"2","CORE BALANCE",0,10,"1","500","100","100",null,"ecrlrlep_facilito","ecrlrlep_facilito","true","[{codigo_producto, \"0010701020\"}, {tipo_trx_pago, \"10120\"}, {tipo_trx_consulta, \"310120\"}, {payment_type, \"electronic_money\"}]"}].
[{denomination_flexible_denomination,236,9,2,"1",
"CORE BALANCE",0,10,"1","500","100","100",null,
"ecrlrlep_facilito","ecrlrlep_facilito","true",
"[{codigo_producto, \"0010701020\"}, {tipo_trx_pago, \"10220\"}, {tipo_trx_consulta, \"310220\"}, {payment_type, \"electronic_money\"}]"},
{denomination_flexible_denomination,239,8,2,"2",
"CORE BALANCE",0,10,"1","500","100","100",null,
"ecrlrlep_facilito","ecrlrlep_facilito","true",
"[{codigo_producto, \"0010701020\"}, {tipo_trx_pago, \"10120\"}, {tipo_trx_consulta, \"310120\"}, {payment_type, \"electronic_money\"}]"}]
2> [ X || {denomination_flexible_denomination, 239, _,_,_,_,_,_,_,_,_,_,_,_,_,_,_} =X <- L].
[{denomination_flexible_denomination,239,8,2,"2",
"CORE BALANCE",0,10,"1","500","100","100",null,
"ecrlrlep_facilito","ecrlrlep_facilito","true",
"[{codigo_producto, \"0010701020\"}, {tipo_trx_pago, \"10120\"}, {tipo_trx_consulta, \"310120\"}, {payment_type, \"electronic_money\"}]"}]
或
3> [ X || X <- L, element(1,X) =:= denomination_flexible_denomination, element(2, X) =:= 239].
[{denomination_flexible_denomination,239,8,2,"2",
"CORE BALANCE",0,10,"1","500","100","100",null,
"ecrlrlep_facilito","ecrlrlep_facilito","true",
"[{codigo_producto, \"0010701020\"}, {tipo_trx_pago, \"10120\"}, {tipo_trx_consulta, \"310120\"}, {payment_type, \"electronic_money\"}]"}]
或
4> list_to_tuple([ list_to_atom("field_" ++ integer_to_list(X)) || X <- lists:seq(1,16) ]).
{field_1,field_2,field_3,field_4,field_5,field_6,field_7,
field_8,field_9,field_10,field_11,field_12,field_13,
field_14,field_15,field_16}
5> rd(denomination_flexible_denomination, v(-1)).
denomination_flexible_denomination
6> [ X || #denomination_flexible_denomination{field_1 = 239} = X <- L].
[#denomination_flexible_denomination{field_1 = 239,
field_2 = 8,field_3 = 2,field_4 = "2",
field_5 = "CORE BALANCE",field_6 = 0,field_7 = 10,
field_8 = "1",field_9 = "500",field_10 = "100",
field_11 = "100",field_12 = null,
field_13 = "ecrlrlep_facilito",
field_14 = "ecrlrlep_facilito",field_15 = "true",
field_16 = "[{codigo_producto, \"0010701020\"}, {tipo_trx_pago, \"10120\"}, {tipo_trx_consulta, \"310120\"}, {payment_type, \"electronic_money\"}]"}]