All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.tonivade.purefun.generic.HMap Maven / Gradle / Ivy

/*
 * Copyright (c) 2018-2019, Antonio Gabriel Muñoz Conejo 
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.purefun.generic;

import com.github.tonivade.purefun.Tuple;
import com.github.tonivade.purefun.Tuple2;
import com.github.tonivade.purefun.generic.HList.HCons;
import com.github.tonivade.purefun.generic.HList.HNil;

@FunctionalInterface
public interface HMap, X extends HList> {

  X map(E head, L list);

  static  HMap map() {
    return (head, list) -> list;
  }

  static , X extends HList> HMap, HCons>
      map(HApply, HCons> apply, HMap mapper) {
    return (head, list) -> apply.apply(head, Tuple.of(list.head(), mapper.map(head, list.tail())));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy