123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354(*
* Copyright (c) 2012 Anil Madhavapeddy <anil@recoil.org>
* Copyright (c) 2011 Richard Mortier <mort@cantab.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)(** Some widely used operators.
@author Richard Mortier <mort\@cantab.net>
@author Anil Madhavapeddy <anil\@recoil.org>
*)(** Pipe. *)external(|>):'a->('a->'b)->'b="%revapply";;(** Element-wise pipe. *)let(||>)lf=List.mapfl(** 32 and 64 bit arithmetic and logic operations. *)(** Addition. *)let(+++)xy=Int32.addxylet(++++)xy=Int64.addxy(** Logical AND. *)let(&&&)xy=Int32.logandxylet(&&&&)xy=Int64.logandxy(** Logical OR. *)let(|||)xy=Int32.logorxylet(||||)xy=Int64.logorxy(** Logical XOR. *)let(^^^)xy=Int32.logxorxylet(^^^^)xy=Int64.logxorxy(** Logical shift-left. *)let(<|<)xy=Int32.shift_leftxylet(<||<)xy=Int64.shift_leftxy(** Logical shift-right. *)let(>|>)xy=Int32.shift_right_logicalxylet(>||>)xy=Int64.shift_right_logicalxy(** Encode string as label by prepending length. *)letcharstrs=letn=String.lengthsinString.make1(char_of_intn)^s,(n+1)