code: public static <K> void updateWeights(double l1, double learningRate, Map<K, Double> weights, Map<K, Double> newWeights) {
          if(l1 > 0.0) {
              /*
              //SGD-L1 (Naive)
              for(Map.Entry<K, Double> e : weights.entrySet()) {
                  K column = e.getKey();
                  newWeights.put(column, newWeights.get(column) + l1*Math.signum(e.getValue())*(-learningRate));
              }
              */
              //SGDL1 (Clipping)
              for(Map.Entry<K, Double> e : newWeights.entrySet()) {
                  K column = e.getKey();
                  double wi_k_intermediate = e.getValue(); //the weight wi_k+1/2 as seen on the paper
                  if(wi_k_intermediate > 0.0) {
                      newWeights.put(column, Math.max(0.0, wi_k_intermediate - l1*wi_k_intermediate));
  
                  }
                  else if(wi_k_intermediate < 0.0) {
                      newWeights.put(column, Math.min(0.0, wi_k_intermediate + l1*wi_k_intermediate));
                  }
              }
          }
      }
docs: Updates the weights by applying the L1 regularization.
  
  @param l1
  @param learningRate
  @param weights
  @param newWeights
  @param <K>