Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

Sidharth Khattri

Ranch Hand
+ Follow
since Sep 16, 2013
Sidharth likes ...
Java Linux Scala
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
8
Received in last 30 days
0
Total given
23
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sidharth Khattri

Two of my colleagues got a chance to visit Amsterdam for scala days, unfortunately I was not one among them.
2 years ago
Self type annotation is used for dependency injection for traits which basically what Cake Pattern is.
Consider it as Tweeter needs an implementation of User instead of considering it as Tweeter has-a User. So, whenever you would like to use Tweeter, you'd have to provide an implementation of User.
3 years ago
context become is just used to switch actor's behavior at runtime.

Upon arrival of any message on MutableStateActor, the receive block changes MutableStateActor's behavior to mutableReceiver, and now the MutableStateActor can only understand messages of type Increment and CounterStatus until unbecome.

As per my understanding become doesn't have any effect in mutating the state of the actor in terms of the counter. You may want to try both piece of code with a bigger set of increments to come to a conclusion.


Edited:
Just for the sake of it, I ran the Actor from the first snippet of code and got the following output:


You can clearly see that the state is still non-deterministic.
3 years ago
I guess second one is more elegant as well as readable.
3 years ago

Sean Corfield wrote:Your best bet is to join the LightTable Discussion group and ask there:

http://groups.google.com/group/lighttable-discussion



A dropped the issue there as well. There are dependency issues.
4 years ago
Using LightTable 0.6.2

Made a new project on terminal:
lein new compojure-app guestbook

Opened it on LightTable and when trying to use Ctrl+Enter, I get this error.
Couldn't find anything on google. Can someone help?

We couldn't connect.

Looks like there was an issue trying to connect to the project. Here's what we got:
final project: ([org.clojure/clojure "1.5.1"] [compojure/compojure "1.1.6"] [hiccup/hiccup "1.0.5"] [ring-server/ring-server "0.3.1"] [org.clojure/tools.nrepl "0.2.3" :exclusions ([org.clojure/clojure])] [clojure-complete/clojure-complete "0.2.3" :exclusions ([org.clojure/clojure])] [ring-mock/ring-mock "0.1.5"] [ring/ring-devel "1.2.1"] [lein-light-nrepl/lein-light-nrepl "0.0.13"] [org.clojure/tools.reader "0.8.3"])
Error loading lighttable.nrepl.handler: java.lang.RuntimeException: Unable to resolve var: reader/*alias-map* in this context, compilingcljs/analyzer.clj:1498:11)
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: lighttable.nrepl.handler/lighttable-ops in this context, compiling/tmp/form-init2952886155223475485.clj:1:3458)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6567)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3624)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6562)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3624)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6562)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5973)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.eval(Compiler.java:6616)
at clojure.lang.Compiler.eval(Compiler.java:6609)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$init_opt.invoke(main.clj:299)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve var: lighttable.nrepl.handler/lighttable-ops in this context
at clojure.lang.Util.runtimeException(Util.java:219)
at clojure.lang.Compiler$TheVarExpr$Parser.parse(Compiler.java:650)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
... 33 more
clojure.lang.ExceptionInfo: Subprocess failed {:exit-code 1}
at clojure.core$ex_info.invoke(core.clj:4327)
at leiningen.core.eval$fn__2081.invoke(eval.clj:226)
at clojure.lang.MultiFn.invoke(MultiFn.java:231)
at leiningen.core.eval$eval_in_project.invoke(eval.clj:326)
at clojure.lang.AFn.applyToHelper(AFn.java:167)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:619)
at leiningen.repl$repl.doInvoke(repl.clj:253)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at leiningen.light_nrepl$light.doInvoke(light_nrepl.clj:56)
at clojure.lang.RestFn.invoke(RestFn.java:423)
at leiningen.light_nrepl$_main.doInvoke(light_nrepl.clj:68)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at leiningen.light_nrepl.main(Unknown Source)

close
4 years ago
Hi Henry, I'm having a hard time thinking of solving the problem recursively. I solved it using iteration at first but the input(N) has to be taken from the user. Can you help?
I'm stuck on a problem. Can anyone please give a hint of how to solve it or please solve this problem. I want to take an input(N) from user and produce the output as follows:

And 0 < N < 101

• For N = 1:

"a", "b", ..., "z".


• For N = 2:

"a", "b", ..., "z",


"aa", "ab", ..., "az",
"ba", "bb", ..., "bz",
.
.
.
"za", "zb", ...,"zz"


• For N = 3:

"a", "b", ..., "z",


"aa", "ab", ..., "az",
"ba", "bb", ..., "bz",
.
.
.
"za", "zb", ...,"zz"


"aaa", "aab", ..., "aaz",
"aba", "abb", ..., "abz"
.
.
.
"baa", "bab", ..., "baz", ...,
.
.
"zaz", "zbz", ..., "zzz".

Since the answer can be quite large I should output it as modulo 1000000007 (10E9 + 7).

How will I loop through these conditions?

Aneek Banerjee wrote:Lets say if I make the instance variables final.Will it be count as Encapsulation?



No, final does not count as encapsulation. Consider the following Example:

though t cannot hold reference to any other object as it's final, but the state of test object that it is referencing to can be changed by any class as it's marked public and not private.

Aneek Banerjee wrote:What is the way other than Access modifiers to implement Encapsulation in Java?



As far as I know, encapsulation can be implemented only by using private access modifier.

Jigar Rathod wrote:tes/xcom folder is having 3 things :

A.java ; A.class ; B.java

------A.java

package xcom;
public class A{}

-------B.java
paclage xcom;
public class B extends A{}


now this thing works if you are in test folder
javac -classpath . xcom/B.java

i modified a bit
javac -classpath xcom/A.class xcom/B.java
this doesn't work
why???



Because the classpath should point to the place where A.class is located. In the above example javac -cp . xcom/B.java should be invoked from tes directory and .(dot) here specifies to look up for any needed classes in the current directory. A.class is not located at xcom/A.class but is located in tes/xcom.

You have to specify the classpath for the class and not the class itself.
Try K&B book as your guide and mock tests in K&B questions book, scjptest, examlab etc.

Amanda Mosby wrote:I am preparing for OCAJP(1z0-803) and OCPJP(1z0-804), i am currently studying using Oracle Certified Professional Java SE 7 Programmer Exams 1Z0-804 and 1Z0-805: A Comprehensive OCPJP 7 Certification Guide by S G Ganesh and Tushar Sharma, I have following queries

  • Is the above one book enough for preparation of OCPJP7 or do i need any other book?, please mention
  • Are there any mockup or test available from the Oracle Press
  • Which mockup is/are best for preparation of OCPJP(804+803)?


  • Few of the one i am able to find out are
  • Enthuware (seperate mockup for both exams)
  • Java Certifications (only 1 mockup for both )
  • Whizlabs (seperate mockup, with combine discounted)


  • Are they any apart from the above mockups?
    Please do mention.



    You can check other mock test websites on this page:
    http://www.coderanch.com/how-to/java/ScjpMockTests

    And see what all include mock tests for OCPJP 7.

    Deepa Sreedhara wrote:Hi,


    Can anyone suggest the best online provider for OCPJP6 certification comparing the mock test materials , cost, etc.



    You don't need to pay anything to practice for mock tests. Try ExamLab, scjptest, K and B mock tests book. These will suffice for your mock test preparation.
    keep in mind that byte b = 7; will compile and byte b = 133; won't. An explicit cast is necessary in the second case.