Questions tagged [dot-operator]

"Dot" operator in Haskell lets us compose one-argument functions with two-argument functions. Can also refer to the "regular" function composition operator, (.).

"Dot" operator in Haskell lets us compose one-argument functions with two-argument functions, like (\x y-> = length $ nub $ intersect x y) = ((length . nub) .) . intersect = (length . nub) .: intersect = length .: nub .: intersect. Should be defined as infixr 9 .:.

More here.

Can also refer to the "regular" function composition operator, (.).

50 questions
66
votes
5 answers

Dot (".") operator and arrow ("->") operator use in C vs. Objective-C

I'm trying to wrap my head around some of the differences in usage and syntax in C vs. Objective-C. In particular, I want to know how (and why) the usage differs for the dot operator and the arrow operator in C vs. Objective-C. Here is a simple…
Charles
  • 865
  • 1
  • 8
  • 9
20
votes
4 answers

Does "T const&t = C().a;" lengthen the lifetime of "a"?

The following scenario is given, to be interpreted as C++0x code: struct B { }; struct A { B b; }; int main() { B const& b = A().b; /* is the object still alive here? */ } Clang and GCC (trunk version as of 2011/02) behave differently:…
Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
7
votes
5 answers

(*it)->method() vs (**it).method

When iterating over an vector (or other container) of pointers, is there any difference between and/or over advantage using: for (it = v.begin(); it != v.end(); ++it) { (*it)->method(); } or for (it = v.begin(); it != v.end(); ++it) { …
Ross
  • 14,266
  • 12
  • 60
  • 91
6
votes
2 answers

Dot operator in haskell with multi-parameter functions

I want to write a function point-free in haskell, to keep things simple lets say I want to make this function: maxmin :: Ord a => a -> a -> a -> a maxmin a b c = max a (min b c) I can improve this to maxmin a b = (max a) . (min b) but is there any…
Erik Henriksson
  • 737
  • 1
  • 6
  • 13
3
votes
2 answers

How do I use dot operator in order to define nested functions in C++?

I want to create functions with dot operator like these: Regedit.Key.Create(); Regedit.Value.Create(); Regedit.Value.Read(); How can I do that?
user10825637
3
votes
3 answers

Combining (a -> Maybe a) and (a -> a) functions

I have two functions: f :: a -> Maybe a g :: a -> a I want to create such function: h :: a -> Maybe a h x | isJust(f x) = Just (g $ fromJust(f x)) | otherwise = Nothing How can I do it in more elegant way?
3
votes
1 answer

Dot or arrow operator vs. scope resolution operator for accessing base subobject

C++ Given a base class Base and a derived class Derived, the first thing constructed by Derived’s constructor is the Base subobject. Since it’s called a subobject, I assumed it can be accessed from client code like any other member object by using…
CodeBricks
  • 1,771
  • 3
  • 17
  • 37
2
votes
2 answers

Why I should use '->' instead of '.' in a pointer of the object?

I agree this might be a very beginner's question, but I have no idea why I can't use '.' to access a member of a pointer to an object. e.g. JMP *sum_obj = new JMP("0"); JMP a; sum_obj->number; a.number; sum_obj.number; // error: request for member…
user21165505
2
votes
1 answer

How to access Sequel result with dot operator in ruby?

I am newbie to Sequel and ruby and I have one thing need your help. In a word, I can't access database query result with dot operator. I am using sequel adapter in padrino ruby project. For example, persons = Person.all persons.each do |p| puts…
Nomura Nori
  • 4,689
  • 8
  • 47
  • 85
2
votes
1 answer

Haskell dot (.) operator in de Morgan's law implementation

In this question, the author has written an implementation of de Morgan's laws in Haskell. I understand the implementations of notAandnotB, and notAornotB, but I'm struggling to understand the implementation of notAorB which is: notAorB :: (Either a…
helencrump
  • 1,351
  • 1
  • 18
  • 27
2
votes
3 answers

Is it possible to call a method in the same line you create an instance in java

class BooleanWrap{ boolean b = new Boolean("true").booleanValue(); } When I try to do the same with the code below, it doesn't work: class TestCode { public static void main(String[] ar) { TestCode tc = new TestCode().go(); …
Nandan747
  • 61
  • 2
  • 5
2
votes
3 answers

How to use (.) in Haskell

I'm trying to write something like this in Haskell: length . nub . intersect but it doesn't work. *Main Data.List> :t intersect intersect :: Eq a => [a] -> [a] -> [a] *Main Data.List> :t nub nub :: Eq a => [a] -> [a] *Main Data.List> :t…
2
votes
2 answers

What does the . operator do in matlab?

I came across some matlab code that did the following: thing.x=linspace(... I know that usually the . operator makes the next operation elementwise, but what does it do by itself? Is this just a sub-object operator, like in C++?
Dan
  • 12,157
  • 12
  • 50
  • 84
1
vote
3 answers

How does it work when I have two methods inside .set() method?

I am new to java, and I need help understanding what the code is trying to do. I am interested on the last line( sd.setId(sh.getGrade().getSchoolId());). I know it is setting using setId in sd object, but then I am bit confused what the rest of the…
pj_max
  • 127
  • 8
1
vote
3 answers

Why lambda expression cannot be dereferenced?

import java.util.*; class TreeMapDemo { public static void main(String args[]) { Comparator c1 = (str1, str2) -> 0; Comparator c2 = (str1, str2) -> 1; TreeMap tm1 = new…
kevin gomes
  • 1,775
  • 5
  • 22
  • 30
1
2 3 4