[erlang-questions] wierd outome on my match method
Hugo Mills
hugo@REDACTED
Sat Jan 31 15:29:57 CET 2015
On Sat, Jan 31, 2015 at 03:11:57PM +0100, Roelof Wobben wrote:
> Hello,
>
> I have made this match method :
>
> match_key( _Key, [] , List) ->
> List ;
>
> match_key( Key, [Head | Tail], List ) ->
> case element(1, Head) of
> Key -> match_key(Key, Tail, [element(2,Head) | List] );
> _ -> match_key(Key, Tail, List )
> end.
>
> match( Key, [] ) ->
> {error, "Instance"};
>
> match(Key, List) ->
> delete_key (Key, List, []).
Is this function really what you mean to do?
Hugo.
> But when I have this database.
>
> Db5 : [{name2,tamara},{name,chantal},{name,roelof}]
>
> and I do this :
>
> Db11 = db:match(name,Db5).
>
> I see this outcome :
>
> [{name2,tamara}]
>
> and when I do this :
>
> Db10 = db:match(name2,Db5).
>
> I see this outcome:
>
> [{name,roelof},{name,chantal}]
>
> So it schould be the other way around.
>
> Can someone help me figure out what went wrong ?
>
> Roelof
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
--
Hugo Mills | O tempura! O moresushi!
hugo@REDACTED carfax.org.uk |
http://carfax.org.uk/ |
PGP: 65E74AC0 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150131/898cf6cb/attachment.bin>
More information about the erlang-questions
mailing list