Prove you're not a pajeet

Well?

i don't know how to program, but maybe I can afford a DNA test

var sum = (a, b) => a + b;
var avg = arr => arr.reduce((a, b) => a + b) / arr.length

Shit, I first thought I'd use a function for reduce, but then remembered it has to be a lambda. UPD:

var avg = arr => arr.reduce((a, b) => a + b) / arr.length

C#

var averageOfList = this.ListOfNumbers.Average(n => n);

Why is this such a problem?

If it's a list of more complex objects it's like:

var averageOfList = this.ListOfNumbers.Average(n => n.ValueYouWantToAverage);

Are you 12?

def avg(arr):
return reduce(arr, lambda a, b: a+b) / len(arr)

But I am.

>find the average of a list of numbers
But can you average two ints in C?

poo => loo

python 3

from functools import reduce

avg = reduce( (lambda x,y:x+y) , l )/len(l)

I don't know

// Go
f := func(list []int) int {
sum := 0
for i := range list {
sum += i
}
return sum / len(list)
}

fmt.Println(f([]int{1,2,7392,72615,62,9}))

Hello, Pajeet

Hello to you, too, another Pajeet

I don't have to code, I have money

What's a lambda expression? I've been programming for 5+ years now and the only lambda I know is the C++ one.

what is pajeet? and what's wrong for being one?

>what is pajeet
slang for indian or south asian

>what's wrong for being one
all the negative stereotypes
dirty
poo in loo
cheap
bad at software

oh shit. i guess im not welcome here.

Can't you just do something like this?


avg :: [Int] -> Int
avg list = (foldl + 0 list) / (size list)

// javascript
let ƛ = (array) => array.reduce((x,y)=>x+y)/array.length
ƛ([1,2,3,4,5]) // 3

//php
$lambda = function($array) { return array_sum($array)/count($array); }
$lambda([1,2,3,4,5]); // 3

You are not welcome anywhere. Even negros have more acceptance

>2016
>not being pajeet master race

//go
package main

import "fmt"

func main() {
ƛ := func(numbers []float64) float64 {
sum := 0.0
for _, num := range numbers {
sum += num
}
return sum / float64(len(numbers))
}
fmt.Println(ƛ([]float64{1, 2, 3, 4, 5}))
}

l not in scope. You FAIL.

# python
l = lambda li: sum(li)/len(li)
print l([1,2,3,4,5])
# 3

dear kind mr stackoverflow can you please teach me how expression of lambda do list of numbers to average? i am very eager of learnings thank you kindly kind sir. kind regards dr. p. kapoor

That's full of errors. Stick to Go or Javascript.

Singly linked list, single pass.
#! /usr/bin/env guile
!#

(use-modules (srfi srfi-1))

(define (avg lst)
(apply / (fold (lambda (x prev)
(list (+ (car prev) x) (+ (cadr prev) 1)))
'(0 0)
lst)))

>Javascript
>Implying I've ever touched that language

Mate stop assuming assumptions it's not cool. I haven't written in Haskell in forever.

//Java
// it looks like shit
// t. junior java dev
public Double getAvg(List intList){
return intList.stream().mapToInt(Integer::intValue).average().getAsDouble();
}


to test:
@Test
public void testIntAvg(){
ArrayList intList = new ArrayList();
intList.add(0);
intList.add(1);
intList.add(2);
intList.add(3);
intList.add(10);

Assert.assertEquals(new Double(2), testClass.getAvg(intList));
}

JavaScript is kiddie shit and doesn't count. Literally anyone can do JS.

>tfw don't know what lambdas are
Can someone tell a c wizard what a lambda is in a sentence?

Anonymous functions(which you can treat like variables)

Sup guys, I'm new to shell scripting.
Anyone got a bash/sh solution please?

Why would anyone want this?

Callbacks, visitor pattern, you name it.

...

They are pretty great when you need to call a one-liner.

...

>use a lambda expression
Why the fuck would i do that?

I don't want to do your homework, madarchod.

#include

No. I don't fizzbuzz unless Im being compensated at University Professor rates this aint welfare codecamp kiddies.

Bullshit. A true C bytefucker would do pointer magic, like placing the ints near each other, than casting the first pointer to a pointer to longint, then moving bits to the right in the value of that pointer.

tfw I can't lambda

glorious ruby mustard race
arr.inject(0) { |a, b| a += b} / arr.size.to_f

data TTree = Leaf Int | Plusbranch TTree TTree | MinusBranch TTree TTree | MulBranch TTree TTree | DivBranch TTree TTree

evalT :: TTree -> Int
evalT (Leaf x) = x
evalT (Plusbranch x y) = eval x + eval y
evalT (MinusBranch x y) = eval x - eval y
evalT (MulBranch x y) = eval x * eval y
evalT (DivBranch x y)
| evalT y == 0 = error "Division by 0
| otherwise = evalT x 'div' evalT y


This made realize the value of functional programming the first time when i saw someone at my university doing this in java with like 200 lines of code and a monster of a architecture structure.

someone outsource this to india

>tfw when your pajeet homeroom teacher was the only person in your boring town in the middle of nowhere that wasn't mentally challenged. Pajeets are cool you guys.

What's this? A Lisp interpreter version 0.0.1?

>life is strange
I like you.

on topic:
I only programmed for about a week in total in my life. I'm weak.

I honestly can't tell the difference between an Indian and a gypsy. They look the same to me. And I fucking hate gypsies, they're scum, they're worse than niggers.
t. eastern european

>lisp users are this delusional

this can be shortened
arr.reduce(:+) / arr.size.to_f

>using bash for math

>lisp users are this delusional
Well it looks like an execution tree parser to me.

There is no solution in bash because bash doesn't have lambda.

Postgresql is better than mysql.

Where are your imports?

>Lisp
Its Haskell dumbass

R

mean(list)

//C
#include
#include
int main() {
printf("gomenasai dev-san, I can't do this lambda shit\n");
exit(EXIT_FAILURE);
}

>intList.stream().mapToInt(Integer::intValue).average().getAsDouble();

wow

lambda x:sum(x)/len(x)

auto getAverage = [](const std::vector& nums) {
int sum = 0;
for (int num : nums)
sum += num;
return static_cast(sum) / nums.size();
};
std::cout

What is a lambda expression at all? I've been programming nearly 20years and this thread is first I've chosen to care about it

Anonymous functions have the same effect as ye olde inline macros but are handled by the compiler rather than a preprocessor. To that extent they represent a more elegant solution than inline macros

(/ (foldl + list) (length list))

can i just take a picture of my toilet instead?

(declaim (ftype (function (symbol) boolean) pajeetp))

(defun pajeetp (symbol)
(get 'not-pajeet 'symbol))

(setf (get 'self 'not-pajeet) t)

int numbers[] = {1, 3, 8, 4, 3, 9, 3, 1, 7, 8, 9};

cout double {
int total;

for (int& i : numbers)
total += i;

return (double)total / (sizeof(numbers) / sizeof(numbers[0]));

}()

I know how to poo in loo.

> Python
f = lambda x : sum(x)/len(x)

# or

def sum(spam):
foo = 0
for i in range(0, len(spam)):
foo += spam[i]
return foo

f = lambda egg : sum(egg)/len(egg)

f = lambda x : sum(x)/len(x)

# or

def sum(spam):
foo = 0
for i in range(0, len(spam)):
foo += spam[i]
return foo

f = lambda egg : sum(egg)/len(egg)

/thread

You don't even need math.h to add and divide

I have a job in info sec.
Done

[](list l) -> int {
int average = 0;
for (auto &e : l)
average += e;
return e/l.size();
}

>desperately trying to project to a group of anonymous people they're smarter than a perceived stereotype
>the question is actually so simple, they may prove they are not the stereotype, but do prove feel threatened by it because it is not far off their own abilities

you're embarrassing yourself, Sup Forums

This is pic of me

Because C++ programmers are a lot like Catholics: anything good or helpful must come with lots of suffering

Integer division, brah

What does lambda do/mean? I would have to make a loop with total += array[i] then divide by the length.

I can read and speak in 6 diferent languages.
I understand another 2 in spoken form.
And I'm Mediterranean white.

I'm also using a tripcode that makes me a faggot.

Read the thread or use Google

I'm googling but I don't understand the explanations.

They're just anonymous functions

So it's just a way for OOP languages to get around the constraints of OOP while telling themselves they are still using OOP?

There ain't no shame in that. Seriously, not even memeing here. I also don't understand why defecating somewhere else other than a toilet elicits so much repulsion from everyone here.

...

No? It's primarily a functional concept that was useful enough that other languages adopted it

Are you retarded?

(fn [l] (/ (reduce + l) (count l)))

fuck off

Greetings pajeet!

fun main(args: Array) {
println(MyMath.sum(listOf(-10, -15, 30, 1, 3, 4, 5)))
println(MyMath.sumLambda(listOf(-10, -15, 30, 1, 3, 4, 5)))
}

object MyMath {
fun sum(numbers: List): Int = numbers.sum();
fun sumLambda(numbers: List): Int = numbers.reduce { a, b -> a + b }
}

You actually made me lol. Wp user.

import lambda
lamba (muh_array)

In Prolog:
average(List, Avg) :- average(List, Sum, 0, Size, 0), Size =\= 0, Avg is Sum / Size.

average([L|List], Sum, AcuSum, Size, AcuSize) :- AcuSumNew is L + AcuSum, AcuSizeNew is AcuSize + 1, average(List, Sum, AcuSumNew, Size, AcuSizeNew).

average([], Sum, Sum, Size, Size).

(* This is OCaml *)
open Core.Std

let average = function
| [] -> 0.0
| _ as lst ->
let sum = List.fold ~init:0 ~f:(+) lst
in float(sum) /. float(List.length(lst))

let () =
assert (average [] = 0.0);
assert (average [1] = 1.0);
assert (average [1;2;3;4] = 2.5)

let () =
printf "Ok\n"

>prove you're not a pajeet

I was asked to find the average of a list of numbers.

I deposited $0.05 into a foreign account, got the code, then resold it to a U.S. corporation for $500.