I am experimenting with bit pattern matching in Erlang:
-module(test). -export([test/2]). %test(P,<<X:P,0:1>>) -> % X. test(P,X) -> <<Y:P,0:1>> = X, Y.
when compiling a commented version, test/2I get a complaint that the "variable" P is "unbound". Is there a good reason not to let the first version work the same as the second?
test/2
Because in the commented version of P, the length - for Erlang to work, must double match - combine the value of the second parameter with an undefined pattern ...
, , " " - " ", , ...
X , , <<Y:P,0:1>> don't match X, !
<<Y:P,0:1>> don't match X
, . .
, P , . , P .
Source: https://habr.com/ru/post/1706635/More articles:How to make a default hybrid map in the Google Maps API? - javascriptHow to convert WMD markdown syntax to HTML on my site? - pythonChanging the default modal result form.showModal - event-handlingDeclarative derived properties for mutable models in Java - javaTracking MySQL Database Changes - databaseHow to save form values ββin data () object? - jqueryN-tier architecture separation of interest design - n-tier-architecturePython Beginner: How to prevent the execution of "finally"? - pythonJQuery hover, image map, loops and arrays - javascriptHow to create a .com file using C / C ++? - c ++All Articles